Jump to content

basic php question? - echo site url


nezona

Recommended Posts

I have this piece of code in my header.php ;-

 

<a href="<? echo SITE_URL; ?>reception/" class="snav" >Reception Areas</a>

 

Now obviously this points to a page on my site called reception. The only problem is im trying to get ready to be search engine optimized, instead of it pointing to the whole of the url, I just want it point to same site link i.e instead of www.primeofficeenviroments.com/reception. I want it to point to /reception.

 

Can anyone help?

 

Neil

Link to comment
https://forums.phpfreaks.com/topic/80763-basic-php-question-echo-site-url/
Share on other sites

Lol. I think i no wat ur talking about but why don't you just get rid of <? echo SITE_URL; ?>?

At the moment ur outputting your a href link as www.website.com/reception however if u just use...

 

<a href="reception/" class=snav>Reception areas</a>

 

it'll work fine

use ./reception/ instead.

 

the ./ means from the current (working) directory (or cwd for short)

 

NOTE:

./ will work if your url is wwwmysite.com as the browser will read reception/ from wwwmysite.com/reception/

 

However if your url is this: wwwmysite.com/dir2/

then the browser will read reception/ from wwwmysite.com/dir2/reception/. As dir2/ is the cwd. Instead you should use ./../reception/. The ../ means backup one level in the directory tree.

Hi thanks guys it worked,

 

apart from....

 

because it's the header.php file, if I go from the home pages www.primeoe.com and click on the a href is works fine and shows the directory www.primeoe.com/reception. If I then click on desks it tries to find www.primeoe.com/reception/desks.

 

is there anywhere around this?

 

kind regards

neil

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.