Routing In Simple PHP from Navigation Menu

537 views Asked by At

I have the root project-folder. Where each php files are in specific folder.
For each nav items, I have passed the php page through href="" tag.
When I click on the nav item it then takes me to the requested page as passed in href. But when from that page if i choose other nav items it says page not found.

  • Project
  • Categories
    1. Page.php
    2. NextPage.php

  • Extras
    1. extra.php

e.g <a href="Categories/page.php">Page</a>
<a href="Extras/extra.php">Extra</a>
When I am on extra.php and choose another nav items from navigation it says object not found. The URI becomes unreachable i.e http://localhost/Project/Extras/extra.php/Categories/page.php"Object Not Found" It should be like http://localhost/Project/Categories/page.php.

2

There are 2 answers

0
P.S. On

Just use absolute links

<a href="/Project/Categories/page.php">Page</a> 
<a href="/Project/Extras/extra.php">Extra</a>
0
adot On

You need to make your tags start from the project root by prefixing all the links with /

<a href="/Project/Categories/page.php">Page</a>