IfModule: When Do We Need to Specify It?

0

Issue

Do you need to enclose your rewrite rules with the following?

<IfModule mod_rewrite.c>
  # Rewrite rules here.
</IfModule>

Assuming mod_rewrite wasn’t turned on, the rules won’t be executed anyway, no?

Solution

If mod_rewrite wasn’t turned on, the rules would generate an error upon starting.

Whenever there’s reason NOT to be sure a module is loaded (“generic” .htaccess used on multiple servers for example), the IfModule tags are useful. If you’re sure the module is loaded, there’s no need for the tags.

Answered By – PtPazuzu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More