non-www. to www. Redirects exclude domain

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 1
Joined: 02 Jun 2016, 10:15

non-www. to www. Redirects exclude domain

02 Jun 2016, 10:29

Hi everyone, i'm trying to exclude some domains and ip as an example from non www redirect, but i dont understand how.

this piece works as well(down here), but when i specialize domain for this redirect it's not works(#commented section), i need to create this redirect for domain

domain1.com
domain2.com
domain3.com
domain4.com

and NOT for

248.24.10.11
248.24.10.12
248.24.10.13
248.24.10.14
domain5.com
domain[N].com

Code: Select all
#non-www. to www. Redirects
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^m.domain\.com$ [NC]
#RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC]
#RewriteCond %{HTTP_HOST} ^domain2\.com$ [NC]
#RewriteCond %{HTTP_HOST} ^domain3\.com$ [NC]
#RewriteCond %{HTTP_HOST} ^domain4\.com$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


Thank you!

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: non-www. to www. Redirects exclude domain

05 Jun 2016, 05:49

Hello.

Please try this:

Code: Select all
#non-www. to www. Redirects
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^m.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(?:domain1\.com)|(?:domain2\.com)|(?:domain3\.com)|(?:domain4\.com)$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 25 guests