I was debugging about some mod_rewrite errors caused by the .htaccess file on one of my sites and couldnâ€™t solve the problem myself so I opted for a help thread on the SitePoint.com forum. Turned out itâ€™s not the problem of my mod_rewrite rules in .htaccess but some incorrect file permissions that were causing the trouble.
Dklynn was very nice to help me in this regard and offered a gold advice that I thought I should share with you.
You Should NOT Use <IfModule></IfModule>. Why?
He pointed out that I should get rid of the <IfModule> conditional from the .htaccess file. Itâ€™s useless and a complete waste of server resources by all means. No excuses.
Considering the fact that all HTTP requests (including those to trivial assets such as .css, .js, .gif, .jpg, etc., thus each web page download would trigger about 10 or even more HTTP requests) to the Apache web server are handled by the rules in your .htaccess file, I think I should get rid of all such <IfModule> conditionals from all .htaccess files on all my sites, or the server would be doing useless check of â€œIf Module xxx Is Enabledâ€ every time a HTTP request is receivedâ€¦..
With a site receiving 1000 page visits per day, your server would have to do 10,000 such useless checks at the cost server resources and performance.
Many famous 3rd party scripts such as WordPress has <IfModule></IfModule> in the .htaccess file by default. This is to prevent potential errors should the module was not installed on the clientâ€™s production site / server. You should try and remove it. If the mod_rewrite and SEO friendly URLs are working, you can remove it without any problems.
This is pure gold advice offered by Dklynn. Check out his site about Apache mod_rewrite.