2014-10-31 110 views
2

我这里有这样的代码在我所有的页面的顶部:基础标签不能正常工作

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

,并在此页面(http://example.com/dev/index.php/foo/bar/)我有这样的代码:

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

但是我的浏览器一直试图装入:

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

当它应该是:

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

**更新**

<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" /> 

难道我做错了什么?

Peter

+0

'风格/'是一个相对的URL。尝试使用'/ style/common.css'而不是 – briansol 2014-10-31 14:59:18

+2

''必须在具有'href'属性的任何事物之前。确保''是第一个。 – JakeParis 2014-10-31 15:00:44

+1

@briansol相对URL与基本元素一起使用。 – JakeParis 2014-10-31 15:06:11

回答

4

我有类似的问题。当页面通过cgi进行传输时发生问题。这并没有为我工作:

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

但是,以下作用:

<base href="/dev/">