I do in the .htaccess file redirect from www to the main host in the following way:

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 

We must make sure that this rule does not apply to robots.txt, that is, there is no redirect to http://www.site.com/robots.txt

    1 answer 1

    I think another RewriteCond form

     RewriteCond %{REQUEST_URI} !robots\.txt 

    before RewriteRule will help you.

    • Then robots.txt is available only from www, if you enter without www you redirect to www. Can I make robots.txt available with and without www? - morganchees