0

I am working on a website. There are on every page equal navs. So I outsourced them into one PHP file where I echo the nav.

So the problem is the pathes are different because I have some files in subdirectories.

My file hierarchy looks like:
- index.php
- logic/
-- drawer.php
- account/
-- login.php

I include the drawer.php in index.php and login.php.
But when I'm linking from index to login, I have a different path as if linking from login to index.

Dafnik
  • 1
  • 2
  • 2
    Use absolute paths. /root/ , ex: /var/www/login.php – clearshot66 Jun 06 '17 at 14:02
  • When I make absulte pathes he writes me the whole address into to address bar. Then it looks like: https://imgur.com/a/570bd – Dafnik Jun 06 '17 at 14:15
  • Please show us your attempt and we might be able to see where you're going wrong. Includes doesn't affect the url. Are you just trying to link to pages or use PHP's `include`? – M. Eriksson Jun 06 '17 at 14:17
  • If it is for links, you should prepend the links with a slash:: `href="/logic/drawer.php"` and so on. Starting a link with `/` will make the link relative from the document root. However, that's not "including" a file, that's linking to a file. – M. Eriksson Jun 06 '17 at 14:21
  • Thank you. I played a little bit with the links and I got it final to work. – Dafnik Jun 06 '17 at 14:29

0 Answers0