了htaccess的重写我的链接,这样更好的SEO:的.htaccess的mod_rewrite挡住了我的CSS
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_URI} .*/([^/]+)/? [NC]
RewriteCond %{REQUEST_URI} !index\.php [NC]
RewriteRule .* /index.php?cat=%1 [L,NC,QSA]
其重写
http://www.example.com/any/number/of/directories/lastDir
到:
http://www.example.com/index.php?cat=lastDir
但我的CSS心不是工作,当我上传htaccess到服务器,只有纯文本没有图像和css
尝试添加基础标签成HTML,但使用
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_URI} .*/([^/]+)/? [NC]
RewriteCond %{REQUEST_URI} !^(index\.php|robots\.txt|img|font|js|css|scripts) [NC]
RewriteRule .* /index.php?cat=%1 [L,NC,QSA]
这会过滤掉某些类型的文件和目录,以确保资产不被重定向它不工作
<base href="http://www.example.com/">
请尝试使用'。* /([^ /。] +)/?'。您的规则可能与css和图像文件匹配。因为文件扩展名包含一个点,所以不要在重写中允许点防止这种情况。 – Gerben 2013-03-11 19:15:03
不适用于example.com/aaaa,仅适用于example.com/aaa/bbb等 – user1590642 2013-03-11 19:32:48