[TYPO3-english] Robots.txt for multiple domains

Gregor Hermens gregor at a-mazing.de
Tue Mar 4 08:26:36 CET 2014


Hi Tony,

Tony Lush wrote:

> In .htaccess I have as the final rewrite rule:
> 
> # Rewrite URL for robots.txt
> RewriteRule ^robots\.txt$ robots/%{HTTP_HOST}.txt [L]
> 
> However, when I go to www.domain1.com/robots.txt I get a page not found
> 404 error.

the last RewriteRule of the default .htaccess acts as a catch-all. You
have to place your additional rules before that, i.e.:

<IfModule mod_rewrite.c>                                                                                                           

  RewriteEngine On                                                                                                                   

  RewriteCond %{REQUEST_FILENAME} !-f                                                                                                
  RewriteCond %{REQUEST_FILENAME} !-d                                                                                                
  RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]

  RewriteRule ^fileadmin/(.*/)?_recycler_/ - [F]
  RewriteRule ^fileadmin/templates/.*(\.txt|\.ts)$ - [F]
  RewriteRule ^typo3conf/ext/[^/]+/Resources/Private/ - [F]

  RewriteRule ^(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]

  RewriteRule ^typo3$ typo3/index_re.php [L]

## Your rules here:
  RewriteRule ^robots\.txt$ robots/%{HTTP_HOST}.txt [L]

## Final catch-all:
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule .* index.php [L]

</IfModule>

hth
Gregor
-- 
http://www.a-mazing.de/   |   Certified TYPO3 Integrator



More information about the TYPO3-english mailing list