Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x support forum
 Helicon Tech : ISAPI_Rewrite 2.x support forum
Subject Topic: Redirect to www Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
mjmillr2
Newbie
Newbie


Joined: 25 March 2008
Location: United States
Online Status: Offline
Posts: 4
Posted: 25 March 2008 at 3:16pm | IP Logged Quote mjmillr2

I'm sure this has been asked before, but I wasn't able to find the answer.  Any help would be appreciated.

I need to redirect (permanent 301) all requests from mysite.com to www.mysite.com.  There could be any number of directories or query string parameters after the domain, and it could be coming in as http or https.

Also I'd like to redirect www.mysite.com/index.html to www.mysite.com.

If anyone can let me know what rules to use, or point me to another post with the answer that would be great.

 

Thanks,

-Mike

Back to Top View mjmillr2's Profile Search for other posts by mjmillr2
 
mjmillr2
Newbie
Newbie


Joined: 25 March 2008
Location: United States
Online Status: Offline
Posts: 4
Posted: 25 March 2008 at 4:01pm | IP Logged Quote mjmillr2

I need to adjust my request a little.   Any request to

www.mysite.com

w1.mysite.com

w2.mysite.com

dev.mysite.com

is ok.  I need to redirect everything else to www.mysite.com.

I have the following rules which almost work

RewriteCond Host: (?!w1\.)(.+)

RewriteCond Host: (?!w2\.)(.+)

RewriteCond Host: (?!dev\.)(.+)

RewriteCond Host: (?!www\.)(.+)

RewriteRule (.+) http\://www.$1$2 [I,RP]

 

Requests to mysite.com get properly redirected to www.mysite.com but requests to mysite.com/product/ also get redirected to www.mystite.com instead of www.mysite.com/product/

Thanks again for any help you can provide.

 

-Mike

Back to Top View mjmillr2's Profile Search for other posts by mjmillr2
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7468
Posted: 26 March 2008 at 10:51am | IP Logged Quote Lexey

RewriteCond Host: (?!w(?:ww|[12])|dev)(?:.*\.)?mysite\.com
RewriteCond %HTTPS (on)|.*
RewriteRule (.*) http(?1s:)\://www.mysite.com$2 [I,RP]
Back to Top View Lexey's Profile Search for other posts by Lexey
 
mjmillr2
Newbie
Newbie


Joined: 25 March 2008
Location: United States
Online Status: Offline
Posts: 4
Posted: 26 March 2008 at 11:38am | IP Logged Quote mjmillr2

Perfect.  Thanks!
Back to Top View mjmillr2's Profile Search for other posts by mjmillr2
 
shroder
Newbie
Newbie


Joined: 27 October 2006
Location: United States
Online Status: Offline
Posts: 3
Posted: 30 March 2008 at 10:02am | IP Logged Quote shroder

Would it be possible to modify this code so that it processes any domain that is passed through it?

So, domain1.com -> www.domain1.com and domain2.com -> www.domain2.com.
Back to Top View shroder's Profile Search for other posts by shroder Visit shroder's Homepage
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7468
Posted: 30 March 2008 at 12:02pm | IP Logged Quote Lexey

RewriteCond Host: (?!w(?:ww|[12])|dev)(?:.*\.)?([^.]+\.[^.]+)
RewriteCond %HTTPS (on)|.*
RewriteRule (.*) http(?2s:)\://www.$1$3 [I,RP]
Back to Top View Lexey's Profile Search for other posts by Lexey
 
thuntoon
Newbie
Newbie


Joined: 06 May 2008
Online Status: Offline
Posts: 2
Posted: 06 May 2008 at 3:22pm | IP Logged Quote thuntoon

I would like to do a 301 Redirect from www.my-site.com to www.mysite.com. I've tried the following without success:

RewriteCond Host: (?!www)(?:.*\.)?my\-site\.com
RewriteCond %HTTPS (on)|.*
RewriteRule (.*) http(?1s:)\://www.mysite.com$2 [I,RP]

Any help is appreciated.

Back to Top View thuntoon's Profile Search for other posts by thuntoon
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7468
Posted: 16 May 2008 at 5:07pm | IP Logged Quote Lexey

RewriteCond Host: www\.my-site\.com
RewriteCond %HTTPS (on)|.*
RewriteRule (.*) http(?1s:)\://www.mysite.com$2 [I,RP]
Back to Top View Lexey's Profile Search for other posts by Lexey
 
thuntoon
Newbie
Newbie


Joined: 06 May 2008
Online Status: Offline
Posts: 2
Posted: 21 May 2008 at 10:37am | IP Logged Quote thuntoon

That worked great.  Thanks.
Back to Top View thuntoon's Profile Search for other posts by thuntoon
 
tsophon
Newbie
Newbie


Joined: 26 June 2008
Online Status: Offline
Posts: 11
Posted: 27 June 2008 at 3:41pm | IP Logged Quote tsophon

Hi,

I would like to do a redirect from http://test.mysite.com/mm5/merchant.mvc to http://test.mysite.com/.

I used the following codes without any success:

DirectoryIndex /mm5/merchant.mvc

RewriteEngine On

# Handles regular requests
RewriteCond %{HTTP_HOST} !^test.mysite.(.*)$ [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ http://test.mysite.com/$1 [R=301,L]

Any advice? I'm really appreciated! Thanks.

Tanya

Back to Top View tsophon's Profile Search for other posts by tsophon
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7468
Posted: 30 June 2008 at 4:03pm | IP Logged Quote Lexey

What ISAPI_Rewrite version are you using? Your rules are for the v3 while you are asking the question in the v2 forum.
Back to Top View Lexey's Profile Search for other posts by Lexey
 
tsophon
Newbie
Newbie


Joined: 26 June 2008
Online Status: Offline
Posts: 11
Posted: 30 June 2008 at 8:55pm | IP Logged Quote tsophon

Hi Lexey,

It is for v3. I am sorry. I just realized I posted it in the wrong forum.

Does v3 support DirectoryIndex?

Thanks.

Tanya

Back to Top View tsophon's Profile Search for other posts by tsophon
 
Yaroslav
Moderator Group
Moderator Group


Joined: 15 August 2002
Online Status: Offline
Posts: 6455
Posted: 01 July 2008 at 8:51am | IP Logged Quote Yaroslav

No, this is not a mod_rewrite directive. You can set up default document in IIS control panel for this web site.

__________________
Yaroslav Govorunov,
Helicon Tech
Back to Top View Yaroslav's Profile Search for other posts by Yaroslav Visit Yaroslav's Homepage
 
tsophon
Newbie
Newbie


Joined: 26 June 2008
Online Status: Offline
Posts: 11
Posted: 01 July 2008 at 9:32am | IP Logged Quote tsophon

Thanks Yaroslav.

I posted another question related to DirectoryIndex in the v3 forum: http://www.helicontech.com/forum/forum_posts-TID-9997-PN-1-TPN-1.htm

Please advise. Thanks.

Back to Top View tsophon's Profile Search for other posts by tsophon
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
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