【发布时间】:2015-11-25 21:54:13
【问题描述】:
让 htaccess 重写我的链接以获得更好的 seo,如下所示:
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
尝试将base标签添加到html中,但它不起作用
<base href="http://www.example.com/">
【问题讨论】:
-
尝试改用
.*/([^/.]+)/?。您的规则可能与 css 和图像文件匹配。不允许重写中的点会阻止这种情况,因为文件扩展名包含一个点。 -
不适用于 example.com/aaaa,仅适用于 example.com/aaa/bbb 等
标签: css .htaccess mod-rewrite