| Author |
|
mjmillr2 Newbie

Joined: 25 March 2008 Location: United States
Online Status: Offline Posts: 4
|
| Posted: 25 March 2008 at 3:16pm | IP Logged
|
|
|
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 |
|
| |
mjmillr2 Newbie

Joined: 25 March 2008 Location: United States
Online Status: Offline Posts: 4
|
| Posted: 25 March 2008 at 4:01pm | IP Logged
|
|
|
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 |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7259
|
| Posted: 26 March 2008 at 10:51am | IP Logged
|
|
|
RewriteCond Host: (?!w(?:ww|[12])|dev)(?:.*\.)?mysite\.com
RewriteCond %HTTPS (on)|.*
RewriteRule (.*) http(?1s:)\://www.mysite.com$2 [I,RP]
|
| Back to Top |
|
| |
mjmillr2 Newbie

Joined: 25 March 2008 Location: United States
Online Status: Offline Posts: 4
|
| Posted: 26 March 2008 at 11:38am | IP Logged
|
|
|
Perfect. Thanks!
|
| Back to Top |
|
| |
shroder Newbie

Joined: 27 October 2006 Location: United States
Online Status: Offline Posts: 3
|
| Posted: 30 March 2008 at 10:02am | IP Logged
|
|
|
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 |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7259
|
| Posted: 30 March 2008 at 12:02pm | IP Logged
|
|
|
RewriteCond Host: (?!w(?:ww|[12])|dev)(?:.*\.)?([^.]+\.[^.]+)
RewriteCond %HTTPS (on)|.*
RewriteRule (.*) http(?2s:)\://www.$1$3 [I,RP]
|
| Back to Top |
|
| |
thuntoon Newbie

Joined: 06 May 2008
Online Status: Offline Posts: 2
|
| Posted: 06 May 2008 at 3:22pm | IP Logged
|
|
|
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 |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7259
|
| Posted: 16 May 2008 at 5:07pm | IP Logged
|
|
|
RewriteCond Host: www\.my-site\.com
RewriteCond %HTTPS (on)|.*
RewriteRule (.*) http(?1s:)\://www.mysite.com$2 [I,RP]
|
| Back to Top |
|
| |
thuntoon Newbie

Joined: 06 May 2008
Online Status: Offline Posts: 2
|
| Posted: 21 May 2008 at 10:37am | IP Logged
|
|
|
That worked great. Thanks.
|
| Back to Top |
|
| |
tsophon Newbie

Joined: 26 June 2008
Online Status: Offline Posts: 11
|
| Posted: 27 June 2008 at 3:41pm | IP Logged
|
|
|
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 |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7259
|
| Posted: 30 June 2008 at 4:03pm | IP Logged
|
|
|
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 |
|
| |
tsophon Newbie

Joined: 26 June 2008
Online Status: Offline Posts: 11
|
| Posted: 30 June 2008 at 8:55pm | IP Logged
|
|
|
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 |
|
| |
Yaroslav Moderator Group

Joined: 15 August 2002
Online Status: Offline Posts: 6451
|
| Posted: 01 July 2008 at 8:51am | IP Logged
|
|
|
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 |
|
| |
tsophon Newbie

Joined: 26 June 2008
Online Status: Offline Posts: 11
|
| Posted: 01 July 2008 at 9:32am | IP Logged
|
|
|
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 |
|
| |