help getting website root directory
I am developing a new site that right now is at http://74.220.207.192/~zluthorg/ . When I'm creating links to images/other pages, I can't just use "/" as the website root directory because that goes to http://74.220.207.192 , instead of http://74.220.207.192/~zluthorg/ . Is there a way to get http://74.220.207.192/~zluthorg/ from a php $_SERVER variable or some other means, so that when the site goes live, I don't have to replace a ton of /~zluthorg/ with just /?
I hope you can understand what I'm trying to do.
Thanks.
Last edited by jrthor2; 02-03-2008 at 12:58 PM .
you could use ./ instead to reference the current dir, that way you don't have to keep adding the path name, but then you run into problems with sub directories...
dirname($_SERVER['PHP_SELF'])
should return the path to the current file(eg: /~zluthorg or whatever). but then that doesn't solve your problem completely, since sub dir's will still cause a problem.
my solution has always been to run a single include in all files carrying several usefull peices of info:
PHP Code:
<?
define ( 'im_path' , '/~zluthorg/' );
define ( 'inc_path' , '/home/www/includes/' );
?>
then just use it like so:
PHP Code:
<img src='<?=im_path ; ?> my_image.png' />
If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
The same applies to HTML and the forums [HTML][/HTML] tags.
so then when the site goes live, the address will be www.zluthorg.com , I just need to change those values to "/" so they point to the web root?
well, includes path is what I use for my includes, and tend to point away from accessible files.
But yeah, you point im_path to '/' when you get your own domain/subdomain.
If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
The same applies to HTML and the forums [HTML][/HTML] tags.
yeah, include files I'm good with, it's just links/images that I don't want to have to change all over my site.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks