问题
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