Forum Topic: Is RewriteCond Necessary?

Forum: .htaccess Forum : Redirecting • Posted by Cyndi • Updated:

I currently have a huge .htaccess file due to a site revamp with each redirect including one of these two RewriteCond…

RewriteCond %{HTTP_HOST} ^.*$


RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$

…followed by the RewriteRule to simply redirect an old page to a new one.

I was wondering if there RewriteCond statements are even necessary. (I have implemented the “redirect to www” code near the top of my file.)

I’m trying to wrap my head around this mod_rewrite stuff and some days it just hurts my head. LOL

3 Replies to “Is RewriteCond Necessary?”

Posted by Jeff Starr

It’s difficult to determine the scope of the directives without looking closer at things, but if you are working on the site it would be possible to test whichever directives you are wondering about.. for example try removing some of the apparently redundant lines and see if anything breaks. Chances are there is a lot of code that can be removed, but without knowing the full story it would be difficult to say for sure one way or another.

Posted by Cyndi •

Okie dokie. I am working on rearranging my .htaccess file so that it is easier to manage since it is so huge and will then remove a condition or two and test it out.

Thanks much!

Posted by Jeff Starr

Yes it just takes time to go through and test things, unfortunately.. if you get stuck with anything specific let me know and I’ll do my best to help.