IfModule doesn't appear to be working?

余生长醉 提交于 2020-01-07 05:36:06

问题


If I use this:

<IfModule mod_rewrite.c>
RewriteEngine On
RedirectMatch 301 ^/training/(.*) /faculty/training.html
</IfModule>

the redirects don't occur.

Same with:

<IfModule mod_rewrite>
...
</IfModule>

However, this works as expected:

RewriteEngine On
RedirectMatch 301 ^/training/(.*) /faculty/training.html

In other words, the redirect works fine outside of the <IfModule> block.

Is there a reason why <IfModule> wouldn't detect mod_rewrite.c?


回答1:


The RedirectMatch directive is part of mod_alias.c and not mod_rewrite.c, You want your IfModule to check for mod_alias.c. You also don't need to turn on RewriteEngine since RedirectMatch doesn't use it.



来源:https://stackoverflow.com/questions/7983328/ifmodule-doesnt-appear-to-be-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!