I am trying to redirect users to an a different url when they access my webapp from a particular url. For example, if they use 192.0.2.4:80
to visit the web app, I want to redirect them to 192.0.2.5:8989
.
This is my .htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_HOST} !http://192.0.2.4:80$ [NC]
RewriteRule ^(.*)$ http://192.0.2.5:8989$1 [L,R=301]
When I access the site using 192.0.2.4:80
it redirect to 192.0.2.5:8989
but it repeatedly concatenates it in the URL bar. For example:
192.0.2.5:8989/192.0.2.5:8989/192.0.2.5:8989/192.0.2.5:8989
etc.
I also get the error ERR_TOO_MANY_REDIRECTS
.
host
header in the HTTP request, which is only the hostname part of the URL and not the full URL, yourRewriteCond
will always be true as HTTP_HOST will never be the stringhttp://192.0.2.4:80