This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: 301 redirect subdomains EXCEPT ’www’
Author
Message |
shoesite
Newbie


Joined: 20 May 2007
Posts: 23
Posted: 20 December 2010 at 10:22am

Hello,
I want to detect where a user types in ANY subdomain EXCEPT 'www', then 301 redirect it to www.shoesite.com.

I have no subdomains in use except for 'www'.
I do not want to do a 301 redirect if www.shoesite.com is correctly typed in.

Examples:
shoesite.com rewrite to: www.shoesite.com
.shoesite.com rewrite to: www.shoesite.com
w.shoesite.com rewrite to: www.shoesite.com
ww.shoesite.com rewrite to: www.shoesite.com
blog.shoesite.com rewrite to: www.shoesite.com
qqqqq.shoesite.com rewrite to: www.shoesite.com
anything.shoesite.com rewrite to: www.shoesite.com

This rule I am using with no problems:
RewriteCond Host: shoesite\.com
RewriteRule (.*) http\://www.shoesite.com$1 [I,U,RP]

Could you please show me how to modify this rule, or should I write a second rule, and in which order should the 2 rules be processed ?

Thank you
JohnP
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 21 December 2010 at 3:06am

Please try to use the following:

RewriteCond Host: (?!www.*).*shoesite\.com
RewriteRule (.*) http\://www.shoesite.com$1 [I,U,RP]

__________________
Regards,
Anton
Back to Top
 
shoesite
Newbie


Joined: 20 May 2007
Posts: 23
Posted: 21 December 2010 at 10:54am

Thank you Anton,

The suggested rule does work in most conditions except it should also find a match in the following examples:

wwww.shoesite.com
wwwww.shoesite.com
wwwwww.shoesite.com
anythingwww.shoesite.com

Can you please suggest a rule to also match these examples ?

Kind regards
JohnP
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 22 December 2010 at 2:00am

Let's try to fix it the following way then:

RewriteCond Host: (?!.*www.*).*shoesite\.com
RewriteRule (.*) http\://www.shoesite.com$1 [I,U,RP]

__________________
Regards,
Anton
Back to Top
 
shoesite
Newbie


Joined: 20 May 2007
Posts: 23
Posted: 22 December 2010 at 10:26am

Anton,

Thank you,
this new rule fails because it matches all conditions where the subdomain is NOT '.*www.*' This is incorrect.

The requirement is to match all conditions where the subdomain is NOT 'www'

Is this possible ?

Regards
JohnP
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 23 December 2010 at 2:54am

Ok, I think I got it.
This must work:

RewriteCond Host: (?!www\.).*\.shoesite\.com
RewriteRule (.*) http\://www.shoesite.com$1 [I,U,RP]


__________________
Regards,
Anton
Back to Top
 
shoesite
Newbie


Joined: 20 May 2007
Posts: 23
Posted: 23 December 2010 at 11:15am

Anton,

Yes, this is working for the required conditions except where a user enters no subdomain i.e. 'shoesite.com' This also needs to be redirected to 'www.shoesite.com'

Is there a way to include this condition, or will i need to use a separate rule ?

Thank you
John
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 24 December 2010 at 3:06am

I think this should work:

RewriteCond Host: (?!www\.).*shoesite\.com
RewriteRule (.*) http\://www.shoesite.com$1 [I,U,RP]

__________________
Regards,
Anton
Back to Top
 
shoesite
Newbie


Joined: 20 May 2007
Posts: 23
Posted: 01 January 2011 at 2:06pm

Anton,

A Happy New Year 2011 to you and the Helicon Tech Team, you are always so helpful to us users, thankyou.

One last request on this topic:

The url 'www.anything.shoesite.com' is not being redirected to 'www.shoesite.com', do you have a suggestion for a rule to cope with this condition ?

Regards
John
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 04 January 2011 at 2:06am

Hello and greetings from Helicon Tech Team! Happy New Year and Merry Christmas!
Please try to use the following code to deal with all your requirements:

RewriteCond Host: (?!www\.shoesite\.com).*
RewriteRule (.*) http\://www.shoesite.com$1 [I,U,RP]

__________________
Regards,
Anton
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum