Home > Net >  301 redirect all except robots.txt file
301 redirect all except robots.txt file

Time:10-22

In my htaccess i have redirect all pages from my domain to main page. This is:

RewriteRule .  http://www.example.com [r=301,nc,l]

I would like just to exclude from this redirect robots.txt file. Is it possible?

CodePudding user response:

With your shown samples please try following .htaccess rules file. Please make sure to clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteCond %{THE_REQUEST} !\s(?:\S*)/robots\.txt/?\s [NC]
RewriteRule . http://www.example.com [R=301,NC,L]
  • Related