Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base tag not working correctly

I have this code here at the top of all my pages:

<base href="http://example.com/dev/">

and in this page (http://example.com/dev/index.php/foo/bar/) I have this code:

<link rel="stylesheet" type="text/css" href="style/common.css" />

However my browser keeps trying to load:

http://example.com/dev/index.php/foo/style/common.css

when it should be:

http://example.com/dev/style/common.css

**UPDATE **

<html>
<head>
        <base href="http://example.com/dev/" />
        <link rel="stylesheet" type="text/css" href="/style/video.css" />
        <link rel="stylesheet" type="text/css" href="/style/common.css" />

Am I doing something wrong?

Peter

like image 763
Peter Stuart Avatar asked Oct 31 '14 14:10

Peter Stuart


People also ask

How do HTML base tags work?

The <base> tag specifies the base URL and/or target for all relative URLs in a document. The <base> tag must have either an href or a target attribute present, or both. There can only be one single <base> element in a document, and it must be inside the <head> element.

What is HTML base href?

Definition and Usage The href attribute specifies the base URL for all relative URLs on a page.

What is base HTML file?

The <base> HTML element specifies the base URL to use for all relative URLs in a document. There can be only one <base> element in a document. A document's used base URL can be accessed by scripts with Node. baseURI . If the document has no <base> elements, then baseURI defaults to location.


1 Answers

I had a similar problem. The problem occurred when the page was fed through a cgi. This did not work for me:

<base href="http://example.com/dev/">

but, the following does:

<base href="/dev/">
like image 77
user2373071 Avatar answered Sep 28 '22 16:09

user2373071