Mobile app version of vmapp.org
Login or Join
Murphy175

: My ip is redirecting to www-ip I have a redirection rule that redirect my any domain.com request to www.domain.com, But if i try open my domain with ip it redirects to www.ip/. I want my site

@Murphy175

Posted in: #301Redirect #Redirects

I have a redirection rule that redirect my any domain.com request to domain.com, But if i try open my domain with ip it redirects to ip/. I want my site to open when i try to open with ip.

for reference this is what my htaccess looks like.

RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ www.%{HTTP_HOST}/ [R=301,L]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Murphy175

1 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie184

You could add another condition (RewriteCond directive) to prevent the redirect happening when an IP address has been requested:

RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTP_HOST} !^d
RewriteRule (.*) www.%{HTTP_HOST}/ [R=301,L]


When the host does not start with and does not start with a numeric digit.

Note that you'll need to clear your cache before testing, as the <ip> to <ip> redirect is likely to have been cached by the browser.

Although it would perhaps be more usual to canonicalise the URL and redirect the IP address to the domain name?

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme