htaccess的重写规则重写CSS文件 [英] .htaccess rewriting rule rewriting css files
本文介绍了htaccess的重写规则重写CSS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个重写规则,使pretty的网址,但其重写CSS,JS等文件了。
I have a rewrite rule to make pretty url but its rewriting css, js and other files too.
我想重写
http://localhost/example/post/?postid=af1ub4zu4y&title=this-is-the-first-post.html
到
http://localhost/example/post/af1ub4zu4y/this-is-the-first-post.html
我想这样
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^post/([^/]*)/(.*\.html) /example/post/?postid=$1&title=$2 [QSA,L,B]
也试过这样的
also tried like these
RewriteCond %{REQUEST_URI} !\.(?:css|js|jpe?g|gif|png)$ [NC]
RewriteRule ^post/([^/]*)/(.*\.html) /example/post/?postid=$1&title=$2 [QSA,L,B]
和
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^.*\.(css|jpe?g|gif|png|js|ico)$ [NC]
RewriteRule ^post/([^/]*)/(.*\.html) /example/post/?postid=$1&title=$2 [QSA,L,B]
但是这些解决方案都为我工作。请参阅并提出任何可能的方式来做到这一点。
But none of these solution are working for me. Please see and suggest any possible way to do this.
推荐答案
尝试把这个规则在 /example/post/.htaccess
:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /example/post/
RewriteRule ^([^/]+)/([^/.]+\.html?)$ ?postid=$1&title=$2 [QSA,L,B,NC]
这篇关于htaccess的重写规则重写CSS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文