This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Redirecting subdomain to www
Author
Message |
bmckillip72
Newbie


Joined: 01 November 2011
Location: United States
Posts: 4
Posted: 01 November 2011 at 5:16pm

Been through a ton of posts here, but none of them seem
to meet the situation we are trying to solve.

We have been using sub-domains, but now want to 301-
redirect traffic from sub-domains back to regular www.

Example:
seattle.domain.com/washington/seattle-apartments.aspx

redirect to

www.domain.com/washington/seattle-apartments.aspx

All we're looking to do is swap out any subdomain NOT
www, with a www. Directory structure is not changing.

I've got this in place:

RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http://www.%1%2 [R=301,L]

But when we test for the example of above, what we end up
with is:
www.seattle.domain.com/washington/seattle-apartments.aspx
Back to Top Visit bmckillip72's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 02 November 2011 at 8:41am

Hello,

Try using the following:

Code:
RewriteCond %{HTTP:Host} ^(?!www\..*)(?:[^.]+\.)?(domain\.com)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http://www.%1%2 [R=301,L]


Regards
Andrew
Back to Top
 
bmckillip72
Newbie


Joined: 01 November 2011
Location: United States
Posts: 4
Posted: 02 November 2011 at 11:02am

Andrew,

Thanks for the quick response.

We made the change and have been testing. All looks good,
except for one scenario.

We've got some URLs with spaces in the parameters.

http://seattle.domain.com/bbrochure-map.aspx?
PId=381&MId=11/23/2011 12:00:00 AM

The rewrite turns back this:
http://www.domain.com/bbrochure-map.aspx?
PId=381&MId=11/23/2011%252012:00:00%2520AM

Which doesn't work.

But I think the fix is to not escape out the characters

RewriteCond %{HTTP:Host} ^(?!www\..*)(?:[^.]+\.)?
(domain\.com)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http://www.%1%2 [R=301,NE,L]

Correct?
Back to Top Visit bmckillip72's Homepage
 
bmckillip72
Newbie


Joined: 01 November 2011
Location: United States
Posts: 4
Posted: 02 November 2011 at 4:40pm

Adding NE to the rewrite rule seems to have corrected the
issue.

Back to Top Visit bmckillip72's Homepage
 

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

Printable version Printable version