This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
Common Questions (Forum Locked Forum Locked)
 Helicon Tech : Common Questions
Subject Topic: large amount of sub-domain redirect
Author
Message |
johneqr
Newbie


Joined: 30 April 2009
Posts: 19
Posted: 18 September 2011 at 7:08am

Hello,

We need to make large amount sub domain URL redirect like this:

RewriteCond %{HTTP:Host} ^www\.mydomain\.com$
RewriteRule ^city1/community1.aspx$ http://city1.mydomain.com/ [NC,L,R=301]

RewriteCond %{HTTP:Host} ^www\.mydomain\.com$
RewriteRule ^city2/community2.aspx$ http://city2.mydomain.com/ [NC,L,R=301]

We found for each RewriteRule, there has to be a RewriteCond ahead of it. Considering the large number of redirect, is there more efficient way to implement these?

Also, currently there are already a few hundreds of flat RewriteRules, and using of mapfile of hundreds of pairs of query strings. what's the best way to manage them, such as prevent unexpected redirect from happening?

Thank you in advance for your advice!

John

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 20 September 2011 at 8:19pm

Hello John,

Please, try using the following if the only thing that changes - identificator for the 'city':


RewriteCond %{HTTP:Host} ^www\.mydomain\.com$
RewriteRule ^city(\d+)/community.*.aspx$ http://city$1.mydomain.com/ [NC,L,R=301]


Regards
Andrew
Back to Top
 
johneqr
Newbie


Joined: 30 April 2009
Posts: 19
Posted: 20 September 2011 at 9:37pm

Hey Andrew,

Thank you for your response!

Actually, city names are all different, and community names are also different. The only pattern is we want to substitute www with sub-domain name, like city names. Other parts of the URL's vary.

It looks if using 2 variables, one in place of cityname, the other for the rest part after cityname/ would solve the problem. Is it doable?

Thanks again for your help!

John

 

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 21 September 2011 at 4:23am

Well, now I do not know where to pass the 'communnity' to.
Try using the following(but I believe this would affect a lot of other similar pages, that match the pattern):

RewriteCond %{HTTP:Host} ^www\.mydomain\.com$
RewriteRule ^([^/]+)/([^./]).aspx$ http://$1.mydomain.com/ [NC,L,R=301]


Regards
Andrew
Back to Top
 
johneqr
Newbie


Joined: 30 April 2009
Posts: 19
Posted: 21 September 2011 at 8:35am

yes, "community" part is the problem. It would need to be redirected to the same communityname under destination URL.

So, is this valid? -

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

with expecting $2 reflect ([^./]).aspx part. I kind of doubt it. Or is there such capacity for the rewriter at all?

Appreciate your help, as always!

John

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 22 September 2011 at 6:03am

This one would be more accurate:

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

Please, provide the rewrite.log for the testing request in case the rule doesn't work.

Regards
Andrew
Back to Top
 
johneqr
Newbie


Joined: 30 April 2009
Posts: 19
Posted: 22 September 2011 at 9:09am

Thank you, Andrew!

Logging is another question I'd like to ask - what level should I put there? We want to have enough info but don't want to see the log file size grow too fast.

Thanks,

John

 

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 23 September 2011 at 5:44am

Amount of '9' is okay. Just turn on logging --> fire request --> disable logging --> open log file.
Logging process has low profile, so it may take a few moments for the request to be logged.

Regards
Andrew
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