Help to simplify rule

Topics: Developer Forum, User Forum
Feb 13, 2009 at 7:45 AM
Hi

I have created the following re-write rule and I'm sure it can be simplified, can anyone help me make it more compact?
The rule has been created for the homepage only, when traffic arrives on https and any subdomain of mysite.co.uk its redirected to http of the same subomain.

#1 Ensure traffic hitting https://[anything].mysite.co.uk is redirected to http
RewriteCond %{HTTPS}               (?:on).*
RewriteCond %{HTTP_URL}              ^/$
RewriteCond %{HTTP_HOST}          ([^\.]+)\.mysite.co.uk$                
RewriteRule ^/(.+)$               http://%1.mysite.co.uk/    [I,R=301]

#2 Ensure traffic hitting https://[anything].mysite.co.uk/?[querystring] is redirected to http with the querystring
RewriteCond %{HTTPS}               (?:on).*
RewriteCond %{HTTP_URL}                    ^/\?(.+)$
RewriteCond %{HTTP_HOST}          ([^\.]+)\.mysite.co.uk$
RewriteRule ^/(.+)\?(.+)          http://%1.mysite.co.uk/?$2     [I,R=301]

#3 Ensure traffic hitting https://[anything].mysite.co.uk/index.[anything]?[querystring] is redirected to http with the querystring
RewriteCond %{HTTPS}               (?:on).*
RewriteCond %{HTTP_URL}                    ^/index.(.+)$
RewriteCond %{HTTP_HOST}          ([^\.]+)\.mysite.co.uk$
RewriteRule ^/(.+)\?(.+)           http://%1.mysite.co.uk/?$2     [I,R=301]

#4 Ensure traffic hitting https://[anything].mysite.co.uk/index.[anything] is redirected to http

I have not written the fourth  one yet as I hope that any assistance will simplyfy it.

Thanks in advance.

M