Regex 未执行重定向规则

Regex 未执行重定向规则,regex,.htaccess,redirect,rule,Regex,.htaccess,Redirect,Rule,我用rubular.com测试了以下重定向规则 ^tags\/([a-zA-Z0-9_-]+)\.html 例如,使用/tags/a-led.html返回/tags/a-led。到目前为止,一切看起来都正常,但当我在htaccess中应用规则时,如下所示 RewriteRule ^tags\/([a-zA-Z0-9_-]+)\.html$ /tags/$1 [R,L] 还有其他一些规则 RewriteRule ^(.*)/(d*)-(.*)\.html$ /showthread.php

我用rubular.com测试了以下重定向规则

^tags\/([a-zA-Z0-9_-]+)\.html
例如,使用
/tags/a-led.html
返回
/tags/a-led
。到目前为止,一切看起来都正常,但当我在htaccess中应用规则时,如下所示

 RewriteRule ^tags\/([a-zA-Z0-9_-]+)\.html$  /tags/$1 [R,L]
还有其他一些规则

RewriteRule ^(.*)/(d*)-(.*)\.html$  /showthread.php?$1 [R,L]
RewriteRule ^(d*)-(.*)\.html$ /threads/$2 [R,L]
没有被处决,不幸的是我没有胶水,原因可能是什么

  • 这条规则看起来不错,当我将它放在一个默认安装apache的空白htaccess文件中时,它就起作用了
  • 确保已加载mod_rewrite并已打开重写引擎(
    RewriteEngine on
  • 如果有其他规则,请确保重定向规则位于执行内部重写或路由的规则之前
  • 确保您的htaccess文件已被读取。您需要在服务器/vhost配置中为
    AllowOverride
    设置正确的设置。设置
    AllowOverride All
    将确保应用htaccess文件中的所有内容

  • 此外,还可以使用[R,L]检查在此规则之前是否设置了任何其他规则。L告诉apache,如果这个规则匹配,就不要处理更多的规则。

    是否打开了重写引擎?是否打开了。我还有一些其他的规则,当你进入
    http://yourdomain.com/tags/a-led.html
    您不会被重定向到
    http://yourdomain.com/tags/a-led
    ?但是其他重定向有效吗?不,我的其他重定向似乎没有问题
    RewriteEngine On 
    RewriteRule ^tags\/([a-zA-Z0-9_-]+)\.html$  /tags/$1 [R,L]