Redirecting HTTPS requests to HTTP

Topics: Developer Forum, User Forum
Jan 8, 2010 at 10:03 AM

Hi there, my intended outcome is to ensure that Google doesn't index the https version of my site, so I've created a robots_ssl.txt file to which I want the Google spider to be redirected when it comes in via the SSL port. My rules are as follows:

RewriteCond %{HTTPS} ^on$
RewriteRule ^robots.txt$ robots_ssl.txt

According to the log, the rule is accepted and is supposedly being applied, but when I visit https://www.assitport.com/robots.txt I am still getting the normal robots.txt file rather than the ssl version, so it seems that the redirect isn't working. My full IIRF.INI file follows in case you need it to figure out where I'm going wrong. Thanks in advance, your work is ENORMOUSLY appreciated!

# Iirf.ini
# site or app-specific ini file
CondSubstringBackrefFlag ~
RewriteLog  c:\temp\iirf.wwwroot
RewriteLogLevel 2
MaxMatchCount 10

RewriteCond %{HTTPS} ^on$
RewriteRule ^robots.txt$ robots_ssl.txt
RewriteRule /services$      /search/ServiceDir.asp



Coordinator
Jan 8, 2010 at 1:28 PM

Whadaya mean, "the rule is accepted and is supposedly being applied"?  Do you mean, the rule is valid and doesn't generate an error message when the filter starts up?

I'd bet the rule isn't matching because URL paths in IIS begin ith a slash.  That means it should be

RewriteRule ^/robots.txt$    /robots_ssl.txt   [L]

(In regexp, the circumflex is beginning-of-line and $ is end-of-line. )

 

Jan 8, 2010 at 7:38 PM

You were 100% right, the lack of a leading slash was the culprit. That'll teach me to copy stuff indiscriminately from Apache examples without being sufficiently careful.

 

Thanks so much! :D