Elijah
Elijah

Reputation: 281

Paths changed in links on 404 page

BASIC SETUP: WAMP server running locally on my PC (running apache 2.2.22 on localhost) Site is placed under /libelle directory .htaccess placed in that directory and it contains only one line

ErrorDocument 404 /libelle/pages/404.html

404.html file is placed in /libelle/pages directory

Here is what's going on:

404 page has the same layout and menu as the original site with same navigation menu pointing to the site pages:

../index.html

what-we-do.html

portfolio.html

contact.html

Last three files are located in the same directory as 404 page, hence no path to them.

Here is what I do:

a)I go the following URL - /libelle/pages/what-we-do.html and get to the page as I should (forum doesn't allow links with localhost, so I replaced it with webroot)

b)I change the url to /libelle/pages/what-we-SOMEWORDSdo.html and get to the 404 page as I should. No problem here.

Everything looks fine. Strange things start happening if instead of changing the html file name as in the link above I change the directory in URL. So, here it goes...

a)I go the following URL - /libelle/pages/what-we-do.html and get to the page as I should

b) I change the url (this time in directory name) to /libeSOMEWORDSlle/pages/what-we-do.html and get to the 404 page as I should.

c) here comes the strange thing.... Now when I place cursor in navigation menu on my 404 page that suppose to take back to my normal site links it shows: /libeSOMEWORDSlle/pages/what-we-do.html

In other words - it shows the changed directory names in the links. I'm not sure how to fix this and overall puzzled by the behaviour. Any ideas as to why this is happening and how to fix it would be much appreciated.

Upvotes: 0

Views: 149

Answers (1)

twaddington
twaddington

Reputation: 11645

The links in your HTML are probably written to use relative, instead of absolute paths. You should use absolute paths like /libelle/pages/what-we-do.html instead of relative paths like ../what-we-do.html. When using relative paths, the browser constructs the link relative to the current path. So if you type in a funky directory name, the path will be built using that directory name, even if it's incorrect. Absolute paths will always be correct.

Upvotes: 2

Related Questions