Jump to content

help: root path


delickate

Recommended Posts

Hi,

I want to get root path and use on links even if i'm in sub to sub folder etc...

suppose my site name is fitness.com and having two subfolder. so url will become

 

http://www.fitness.com/dir/dir_sub

 

here i want to put a link to go to root directory file. there are different ways to do that. e.g:

 

<a href='../../filename.php'>go to that page</a>

 

but i want to use some constant that always shows to root directory. as i defined here

 

define("SERVER_NAME"	, $_SERVER['HTTP_HOST']);
//and used it like this
<a href='<?php echo SERVER_NAME;  ?>/filename.php'>go to that page</a>

 

it works when we're on root directory. but when we go to sub directory it added sub directory name with it. which i don't want.

 

is there any way?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/260189-help-root-path/
Share on other sites

Thanks ocpaul20,

but document root show the absolute path. which i don't want. i need virtual path. yea session is a great idea.

 

Thanks dragon,

You choose a smart move. I like it. the method will definitely work. Thank a lot.

 

Thanks all of guys... it is really a help full.

Link to comment
https://forums.phpfreaks.com/topic/260189-help-root-path/#findComment-1333632
Share on other sites

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.