4

Hey Stack Overflowers.

I have been stumped and cannot get this correct, I just want to exclude two files, in the root directory, robots.txt and sitemap.xml from https. The rest of the site over https, no problem. I got this:

# Forcing HTTPS
# RewriteCond %{SERVER_PORT} !^443$  
# RewriteCond %{REQUEST_URI} !^sitemap.xml$
# RewriteCond %{REQUEST_URI} !^robots.txt$
# RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [L]

Which clearly results in redirect loops etc. So... any help for an htaccess noobie?

JCVA
  • 43
  • 1
  • 6

1 Answers1

2

Try this rule:

RewriteEngine On

RewriteCond %{SERVER_PORT} !^443$  
RewriteCond %{THE_REQUEST} !/(robots\.txt|sitemap\.xml)\s [NC]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,NE,R=302]

Test this out in a new browser.

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • 1
    Legend. Seems to be working. Thats 5 hours learning for me. Thanks so much, time to test it out a bit!!! – JCVA Mar 30 '15 at 20:44