non-www and ip rewrite

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 1
Joined: 04 May 2012, 09:07

non-www and ip rewrite

04 May 2012, 09:09

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]

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: non-www and ip rewrite

07 May 2012, 06:55

Hello,

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

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 22 guests