IfModule doesn't appear to be working?

2019-08-29 22:40发布

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条回答
Anthone
2楼-- · 2019-08-29 23:27

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.

查看更多
登录 后发表回答