.htaccess RewriteRule,它给我的页面没有CSS

时间:2014-06-01 01:25:49

标签: apache .htaccess

我想更改我的网址www.mywebsite.com/team.php 到www.mywebsite.com/team/使用.htaccess。

我试过这段代码

RewriteEngine On
RewriteRule  ^equipe/?$    equipe.php     [NC,L]

现在我可以访问www.mywebsite.com/team.php和www.mywebsite.com/team/,但是当我访问www.mywebsite.com/team/时,没有css在所有。 是关于服务器配置问题还是代码问题?谢谢!

1 个答案:

答案 0 :(得分:0)

听起来像你的CSS链接问题

如果您使用

定义了css
<link rel="stylesheet" type="text/css" href="mystyle.css">

通过www.mywebsite.com/team.php访问时,可能会在www.mywebsite.com/style.css

中查找您的css文件

通过www.mywebsite.com/team/访问时,它可能会在www.mywebsite.com/team/style.css找到您的css文件而不是返回404。

如果这是您的问题,请使用css href中的/始终在Web服务器的根目录中声明您的css文件,以便无论有多深,所有包含该代码段的网页都会正确加载他们是(或似乎是)的文件夹。

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