include() Across Different Directories
Posted: Thu Apr 20, 2006 9:47 am
I have a folder called /www that contains the pages for http://www.mysite.com. Within that /www folder is a header.php, which is my standard header for all my pages. Pretty much all pages within the /www folder have an include("header.php") line in them at some point. header.php is pretty basic, mostly just images and links, nothing too fancy.
Within the /www folder is another folder called /admin. If I try to include the header.php file in a page within /www/admin, the relative links are incorrect, causing me to get dead links and missing images. If I change the links and images in the header.php file to include ../, this works for my /www/admin problem, but if I want a /www/admin/blah, it's broken again.
Is there a better way to accomplish this without having to hard code the full URL in my header.php (http://www.mysite.com/style.css rather than style.css or ../style.css for example)? I would also like to avoid having multiple header.php files, but I guess this is always an option.
Within the /www folder is another folder called /admin. If I try to include the header.php file in a page within /www/admin, the relative links are incorrect, causing me to get dead links and missing images. If I change the links and images in the header.php file to include ../, this works for my /www/admin problem, but if I want a /www/admin/blah, it's broken again.
Is there a better way to accomplish this without having to hard code the full URL in my header.php (http://www.mysite.com/style.css rather than style.css or ../style.css for example)? I would also like to avoid having multiple header.php files, but I guess this is always an option.