Jump to content

PHP includes for templates - relative link problems


adeking

Recommended Posts

Hi,

 

I am looking to build up a website using multiple pages for each component that makes a page - i.e Header, sidebar etc etc.

 

I have decided to build up each page using php include statements.  I have immediately became stuck with relative links.  The sidebar.php file which includes navigational elements is saved within an includes folder. 

 

Once I have added this page to the home page for example (which is saved in the root), none of the links work as they are relative and the page is saved in a different path.

 

I know that a lot of web design agencies use php includes to build up templates in this way so I am sure there must be a solution.

 

Many thanks for your time and I hope I have explained myself.....

Links that don't have anything, are relative to the domain.

 

<a href="/page.html">Link</a>

 

Links to www.yoursite.com/page.html

 

You may want to try to explicitly specify the links you're trying to point to.

 

<a href="/dir/folder/page.html">Link</a>

 

Or use aliases in .htaccess or your apache conf.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.