Getting error 500 when adding RewriteCond with .to domain
I am trying to redirect traffic coming from a specific domain inside my .htaccess file. It works fine unless I do this for a domain with a .to extension. Any idea what is going on here?
Produces error 500:
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.to [NC]
RewriteRule ^.*$ /foo/bar [L]
Works fine:
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com [NC]
RewriteRule ^.*$ /foo/bar [L]
开发者_开发技巧
Since I do not know for sure which rule does produce rewrite loop, I can only suggest this approach at this moment:
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.to [NC]
RewriteCond %{REQUEST_URI} !^/foo/bar
RewriteRule ^.*$ /foo/bar [L]
Your attempt is not technically correct for 2 reasons:
- in .htaccess URL will be without leading slash (I'm referring to
$1
); - you are using
$1
.. but you have no matching group setup (in other words$1
will always be empty).
If still nothing -- please provide real htaccess ... or try enabling rewrite debugging (RewriteLogLevel 9
) -- but for this you have to have full control over Apache server, as this directive cannot be placed in .htaccess (only server config / virtual host context) + you will need to restart Apache to re-read configuration file.
Try adding this rule somewhere on the top -- where it will be appropriate:
# do not do anything for already existing files
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
精彩评论