Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: Add www to url (Topic Closed Topic Closed) Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
DazednConfused
Newbie
Newbie


Joined: 24 July 2007
Location: Canada
Online Status: Offline
Posts: 18
Posted: 14 August 2007 at 3:39pm | IP Logged  

Hi I know this sounds simple but my futile mind can't seem to handle it.  I was unable to search the forums to see if this has already been covered as it kept timing out.

Ok.  So if someone goes to my site like this "mysite.com" I would like to automatically redirect them to "www.mysite.com" .  Is this possible?  Of course something like "mysite.com/product/test.asp", I would like to be redirected to the same but with the www in front of it.  Thanks for any help you can provide.

 

Dazed

Back to Top View DazednConfused's Profile Search for other posts by DazednConfused
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10483
Posted: 15 August 2007 at 3:30am | IP Logged  

Here's what you need:

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


__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
DazednConfused
Newbie
Newbie


Joined: 24 July 2007
Location: Canada
Online Status: Offline
Posts: 18
Posted: 15 August 2007 at 7:34am | IP Logged  

Wow thanks.  I won't pretend to understand it but thank you very much for the quick support.
Back to Top View DazednConfused's Profile Search for other posts by DazednConfused
 
biott
Newbie
Newbie


Joined: 23 March 2006
Online Status: Offline
Posts: 14
Posted: 15 August 2007 at 10:52pm | IP Logged  

I have a slightly different issue: I want to do the www redirect as above and add a "/" to the end of the folder if it does not have one. I am using the following code:

#Fix non www to www
RewriteCond Host: mysite\.com
RewriteRule (.*) http\://www.mysite.com$1 [I,RP]

#Fix missing slash char on folders
RewriteCond Host: (.*)
RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,RP]

This works great if only one of the two above conditions is met but since the RP causes the url rewriting to stop and sends the redirect immediately, if both conditions are met it sends the redirect which then comes back through a second time to catch the second condition for rewrite. (This may not be a problem but I am thinking the search engines would prefer to not be sent compounding redirects)

Is there a better way to accomplish the above two things in just one rule?
Back to Top View biott's Profile Search for other posts by biott
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10483
Posted: 16 August 2007 at 3:10am | IP Logged  

Try it like this:

#Fix non www to www
RewriteCond Host: mysite\.com
RewriteRule ([^.?]+[^.?/]) http\://www.mysite.com$1/ [I,RP]

RewriteCond Host: mysite\.com
RewriteRule ([^.?]+) http\://www.mysite.com$1 [I,RP]



__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
avsune
Newbie
Newbie


Joined: 15 June 2007
Location: United States
Online Status: Offline
Posts: 9
Posted: 23 August 2007 at 11:56am | IP Logged  

I have this code in my httpd.ini

# Rewrite all .http://<whatever>.<domain> to .www.<whatever>.<domain>
RewriteCond %HTTPS off
RewriteCond Host: (?!www\.)(.+)
RewriteRule (.+) http\://www.$1$2 [I,RP]

# Rewrite all .https://<whatever>.<domain> to .www.<whatever>.<domain>
RewriteCond %HTTPS on
RewriteCond Host: (?!www\.)(.+)
RewriteRule (.+) https\://www.$1$2 [I,RP]

it works for most of the websites on my server but for some rason it doesnt work for one - see http://chumbadeals.com/

Back to Top View avsune's Profile Search for other posts by avsune Visit avsune's Homepage
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10483
Posted: 27 August 2007 at 3:19am | IP Logged  

Try to change the first part like this:

RewriteCond %HTTPS off
RewriteCond Host: (?!www\.)(.+)
RewriteRule (.*) http\://www.$1$2 [I,RP]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 

Sorry, you can NOT post a reply.
This topic is closed.

  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