Forum Moderators: phranque

Message Too Old, No Replies

leading slash not working

         

ads112001

1:57 pm on Aug 5, 2011 (gmt 0)

10+ Year Member



I have 1 site setup locally running apache just fine. All the files utilize a leading slash and always start at the base root however php includes force me to use a relative path.

<?php include("/inc/header.html"); ?>
doesn't work on a page that's 3 directories into the site but
<?php include("../../../inc/header.html"); ?>
does. However i'm using
/about
for my hrefs on that same page and it takes me to
http://mysite.com/about


Any thoughts? Ideally i'd like to just use leading slashes on everything like my 1st site.

g1smd

2:48 pm on Aug 5, 2011 (gmt 0)

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



"Includes" use the local system filepath as seen from inside the server.

"Href" uses URLs on the web as seen from outside the server.

That's the crucial difference.

You can set the default PHP 'includes' path in your .htaccess file.

ads112001

3:57 pm on Aug 5, 2011 (gmt 0)

10+ Year Member



You're so smart. That makes sense now. Thank you for your help!