Include takes wrong url path

Asked

Viewed 201 times

3

  • Use the absolute path, or http://www.w3schools.com/tags/tag_base.asp

  • @user5978 the bad thing is that if use like this, when playing for the server I will have to change the way there too.

  • I see no other solution to this, because what generates the "problem" is the behavior of the browser, and not of your system, so it is "out of your reach".

  • <?php include ("../../_template/_layout.html"); ?>

  • The best way is how @mauhumor spoke using the base tag. But you can popular it using the php $_SERVER global variable, using the SERVER_NAME and REQUEST_URI values

1 answer

2


The solution found was to pass the absolute path to include in the following way:

include $_SERVER["DOCUMENT_ROOT"].'/medic/views/_template/_layout.html';

For links, the ideal would be to use the $_SERVER['SERVER_NAME']:

<a href="http://<?=$_SERVER['SERVER_NAME']?>/medic/index.php"></a>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.