Forum Moderators: coopster

Message Too Old, No Replies

Absolute and Relative URLs

Can't get the declaration to work

         

Francis

5:12 pm on Oct 2, 2004 (gmt 0)

10+ Year Member



Can anybody help?

I have a settings script that contains this:

define("MAIN_SITE_ROOT", "http://www.xyz123.com/");

which I primarily use to include (or require) certain files, images, etc. on our site by using <?php echo(MAIN_SITE_ROOT)?>

For example:
<?php echo(MAIN_SITE_ROOT)?>images_submenu/lost_pass_over.jpg

The problem now is that the server does not support include and require statements that use absolute URLs instead of absolute or relative paths on the server.

The problem is I want to fully qualify the path, so that all my links, images, etc. can be changed by just changing the MAIN_SITE_ROOT declaration in the settings.php file.

How can I do this or is there any work around?

Thanks a lot for the help... again. :-)

ergophobe

5:38 pm on Oct 2, 2004 (gmt 0)

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



Assuming that the files are in fact on the same server as the script that is trying to do the includes, you should not ever use URLs for includes - it's an order of magnitude slower and just creates work for the server. So this isn't a bad thing.

Just do something like this

include($_SERVER['DOCUMENT_ROOT'] . '/path/to/include/file.inc.php');

You may be limited to includes that are within web root.

Tom