non-www and ip rewrite
2 posts
• Page 1 of 1
non-www and ip rewrite
I use this to rewrite a non-www to www and exclude if an IP, but how do I modify this to also handle rewriting the IP to the www URL assuming the IP is 1.1.1.1?
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!(?:www\.|\d))(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!(?:www\.|\d))(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: non-www and ip rewrite
Hello,
Please, try using the following:
Regards
Andrew
Please, try using the following:
- Code: Select all
RewriteCond %{HTTPS} (on)?
RewriteCond %{REMOTE_ADDR} ^1\.1\.1\.1$
RewriteCond %{HTTP:Host} ^(?!(?:www\.|\d))(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
Regards
Andrew
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests