1

I have an .htaccess file with a rewrite rule to get a redirect of every HTTP request to HTTPS.

But now I have a problem that my robots.txt is not recognized by some online checker. If I remove the redirect from the .htaccess file the robots.txt is recognized correctly.

Maybe I should exclude that the robots.txt is redirects to an HTTPS connection?

This is the part of .htaccess for redirecting to HTTPS

RewriteCond %{SERVER_PORT} !^443$            
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L] 
0

How about including this rule:

RewriteCond %{REQUEST_URI} !^robots.txt$

That should only trigger for requests that aren't for robots.txt...

  • Thank you. I think there should be a $1 between RewriteCond and ! but than this is working. – user224013 Jun 12 '14 at 14:52
  • whoops, yeah. I edited my otherwise sloppy answer. I think the Request_URI bit is probably a bit better method. – Christopher Karel Jun 12 '14 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.