boop
boop

Reputation: 7788

Why is this interpreted as absolute url?

I want to hide my gitweb instance behind a reverse proxy. So I set my base url to /gitweb but some URLs are still broken.

As I debugged the problem I found that the following stylesheet is loaded from /gitweb.css instead of /gitweb/gitweb.css.

<base href="/gitweb" />
<link rel="stylesheet" type="text/css" href="gitweb.css"/>

I've found a fix for this problem which says these links are interpreted as absolute urls. Unfortunately I'm not using Apache - which was used in the fix.

Anyway. I'm just wondering why href="gitweb.css" is not using the base href

Upvotes: 2

Views: 66

Answers (1)

Markus
Markus

Reputation: 4149

He does, but the missing slash makes that the browser thinks "gitweb" is a page and only use the "/". Which is the same as base.

See: https://stackoverflow.com/a/1889957/4516689

Or the example in the spec: http://www.w3.org/TR/html5/document-metadata#the-base-element

<!DOCTYPE html>
<html>
    <head>
        <title>This is an example for the &lt;base&gt; element</title>
        <base href="http://www.example.com/news/index.html">
    </head>
    <body>
        <p>Visit the <a href="archives.html">archives</a>.</p>
    </body>
</html>

The link in the above example would be a link to "http://www.example.com/news/archives.html".

Upvotes: 3

Related Questions