: 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
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]
More posts by @Murphy175
1 Comments
Sorted by latest first Latest Oldest Best
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?
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.