You may have noticed I included an "IfModule" wrapper round all the .htaccess mod_rewrite codes in the examples section.
# Place your mod_rewrite code here
If you are distributing a script that uses mod_rewrite, you need to ensure your script is as portable as possible. It should work as many different environments as possible.
When you attempt to turn on the RewriteEngine on a server without the mod_rewrite module enabled, you will cause a 500 Internal Server Error every time a request is made to that directory.
For obvious reasons, that is a tad undesirable. To make a code portable and cross-platform, we can surround all our mod_rewrite lines in an IfModule conditional tag.
The lines inside the <IfModule mod_name.c>IfModule> will only be used if that particular module is enabled on that server.
That allows you to distribute .htaccess files safely, without causing any problems if mod_rewrite is not enabled.