RewriteRule .htaccess不能正常工作

时间:2016-09-22 08:30:15

标签: html apache .htaccess mod-rewrite

我已经改变了我的.htaccess来制作漂亮的网址。 这有什么不对?

e.[BusinessEntityID]

我从中得到了 .htaccess rewriteRule conflict

我会这样做

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-/]+).html$ article.php?url=$1 [NC,L]
RewriteRule ^([a-zA-Z0-9-/]+).html/$ article.php?url=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^category/([a-zA-Z0-9-/]+).html$ category.php?cat=$1 [NC,L]
RewriteRule ^category/([a-zA-Z0-9-/]+).html/$ category.php?cat=$1 [NC,L]

这是数据库中的网址

localhost/category/bla.html

localhost/seo/bla.html

1 个答案:

答案 0 :(得分:1)

只需将底部向上移动

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^category/([a-zA-Z0-9-/]+).html$ category.php?cat=$1 [QSA,L]
RewriteRule ^category/([a-zA-Z0-9-/]+).html/$ category.php?cat=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-/]+).html$ article.php?url=$1 [L,QSA]
RewriteRule ^([a-zA-Z0-9-/]+).html/$ article.php?url=$1 [L,QSA]