'When clicking Home button, url is showing full path instead of just index.php
I just uploaded my htdocs folder to public_html in my web hosting service, and the website works correctly, but when pressing the Home button the URL displays the entire server path.
<div>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="shop.php">Shop</a></li>
<li><a href="contact.php">Contact</a></li>
<li><a href="local_stores.php">Local Stores</a></li>
<li><a href="login.php">Store Login</a></li>
</ul>
</div>
I expect the Home button to bring me back to mydomain.com instead of mydomain.com/home1/company/public_html/mydomain.com
Solution 1:[1]
When you just enter the file name, html always prepends the path.
Try using <a href=“/index.php“>Home<a>
The / tells the browser to go for domain.tld/index.php
Solution 2:[2]
Figured it out! When in development using XAMP and text editors, you use "index.php" and "otherpage.php" in the a tags. But when in the hosting service, to go back to the "index.php", the href value should be "/" because it'll automatically look for the index.php in the directory it's in.
I used this stack thread to solve the issue:
Solution 3:[3]
when you are trying to go back to home page try this
Home use only / in your href="/"
this is indicate to index.php and it will not show in your url
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Don't Panic |
| Solution 2 | Lucas Bassoli |
| Solution 3 | Vivek s |
