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?
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.