I have my website www.example.com and i have a page at www.example.com/site.
If i create a link at that website like this <a href="/something.html">button</a>
then it redirects me to www.example.com/something.html.
Is there any solution to this without changing the href link, so it redirects to www.example.com/site/something.html?
I'm using apache2 to host the site.
Thanks
CodePudding user response:
<a href="/something.html">button</a>
You need to appoint the folder, so you could do:
<a href="site/something.html">button</a>
or you could do:
<a href="https://www.example.com/site/something.html">button</a>
CodePudding user response:
Assuming you're already in the site
folder when you try to go to something.html
which is also in the site
folder, you would use
<a href="something.html">button</a>
The slash /
in front of your link address is telling the browser to go to the root directory www.example.com
and then find something.html
. That's why you end up with www.example.com/something.html
.
So again, just use <a href="something.html">button</a>
.