【问题标题】:RewriteRule .htaccess not working multipleRewriteRule .htaccess 不能多次工作
【发布时间】:2016-09-22 08:30:15
【问题描述】:

我已经更改了我的 .htaccess 以制作漂亮的 url。 这有什么问题?

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]

我从中得到了 .htaccess rewriteRule conflict

我想做这样的

localhost/category/bla.html

localhost/seo/bla.html

这是数据库中的网址

bla.html
seo/bla-bla.html

【问题讨论】:

  • 您要达到的网址是什么,原始网址是什么,请单独提及。
  • 谢谢,我搞定了。

标签: html apache .htaccess mod-rewrite


【解决方案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]

【讨论】:

    猜你喜欢
    • 2019-03-17
    • 1970-01-01
    • 1970-01-01
    • 2018-06-18
    • 2012-09-23
    • 1970-01-01
    • 1970-01-01
    • 2012-12-10
    • 1970-01-01
    相关资源
    最近更新 更多