Forum Moderators: phranque
I've entered a redirect code into the .htaccess according to one's IP:
RewriteCond %{REMOTE_ADDR} ^80\.178\.57\.190$
RewriteRule .* /index.HTML
It worked, but today I started to get this error:
Bad Request
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.
Would anyone know what could be the cause?
Thanks!
The 400 Bad Request was likely caused by a nuisance or malicious attacker -- a badly-coded script sent a bad request to your server.
But your code, as written, will rewrite *anything* to /index.HTML, including requests for /index.HTML itself, so you've set yourself up for an 'infinite' rewrite loop here.
An example fix would be:
RewriteCond %{REQUEST_URI} !^/index\.HTML
RewriteCond %{REQUEST_URI} !^/path_to_custom_400_error_page
RewriteCond %{REQUEST_URI} !^/path_to_custom_401_error_page
RewriteCond %{REQUEST_URI} !^/path_to_custom_403_error_page
RewriteCond %{REQUEST_URI} !^/path_to_custom_404_error_page
RewriteCond %{REQUEST_URI} !^/path_to_custom_410_error_page
RewriteCond %{REQUEST_URI} !^/path_to_custom_500_error_page
RewriteCond %{REQUEST_URI} !^/path_to_custom_503_error_page
RewriteCond %{REMOTE_ADDR} ^80\.178\.57\.190$
RewriteRule .* /index.HTML [L]
Jim