Forum Moderators: coopster

Message Too Old, No Replies

server folder?

         

jackvull

10:54 am on Jul 22, 2008 (gmt 0)

10+ Year Member



How do I get the server folder to be returned?
I access a site via http://example.com/FolderName/index.php

I want to header it back to http://example.com/FolderName/somethingelse.php

but because I have a development and live site, the folder names are different.
Anyway to pick up http://example.com/FolderName/

[edited by: dreamcatcher at 12:34 pm (utc) on July 22, 2008]
[edit reason] use example.com. Thanks. [/edit]

Sekka

11:03 am on Jul 22, 2008 (gmt 0)

10+ Year Member



You could parse it out of $_SERVER variables, but it might be best to do a hard coded setting.

jackvull

11:55 am on Jul 22, 2008 (gmt 0)

10+ Year Member



hard coding in the dev environment means that everytime the page is released to live, the code also has to be changed.
PHP_SELF works but then I need to take off everything after the last forward slash /

?

Sekka

6:50 pm on Jul 22, 2008 (gmt 0)

10+ Year Member



Hard coding would not be an issue if you have the setup in an external file.

You would in theory never need to upload this setup again, so you can have one local and one live.

As for parsing the PHP_SELF, strrpos gets the last occurance of a needle within a string.

$url = substr ($_SERVER['PHP_SELF'], 0, strrpos ($_SERVER['PHP_SELF'], "/") + 1);

brotherhood of LAN

6:54 pm on Jul 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



i'll sometimes define these kind of variables in db.php along with default variables.

i.e. paths to command line tools, different database names, server ip addresses (for when running cron jobs that need to know them) etc.