Zlotz
Zlotz

Reputation: 351

links, CSS and icon require absolute paths in HTML (relative paths not working)

I'm aware that my question is a basics, but still I'm struggling.

I don't understand why my link <a href="Articles/every_ethic_without_dead_end_is_utilitarian.html"> doesn't work (Your file couldn’t be accessed - ERR_FILE_NOT_FOUND error) while:

My file tree is:

├── drwxrwxr-x Articles
│   └── -rw-rw-r-- every_ethic_without_dead_end_is_utilitarian.html
└── -rw-rw-r-- index.html

According to this page (for example) it should work but it still doesn't.

When I open index.html in a browser, the URL is <absolute path to the website repository>/index.html. And, when I click on the link and get the error, the URL is file:///Articles/every_ethic_without_dead_end_is_utilitarian.html.

And I've got the same problem for the CSS files and the icon file: it works with absolute paths but not with relative ones.

Upvotes: 0

Views: 45

Answers (1)

Zlotz
Zlotz

Reputation: 351

There was <base href="/"> in the <head> element.

No idea how this happened.

Sorry.

Upvotes: 0

Related Questions