This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
Common Questions
 Helicon Tech : Common Questions
Subject Topic: non-www to www using isapi_rewrite Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
gsp
Newbie
Newbie


Joined: 11 January 2011
Online Status: Offline
Posts: 25
Posted: 11 January 2011 at 5:26am | IP Logged Quote gsp

Hi

I need to direct non-www to www both for my main and as well as subdomains

I added the below code in httpd.ini located in root but it is not working.

[ISAPI_Rewrite]

# check to make sure it's not a www or subdomain request
rewritecond %{http_host} ^[a-zA-Z]+\.com
# if that's the case, rewrite to www.http_host
RewriteRule (.*) [%{http_host}...] [R=301,L] ]

Can any one please advice. Thanks in advance.

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


Joined: 11 January 2011
Online Status: Offline
Posts: 25
Posted: 11 January 2011 at 5:38am | IP Logged Quote gsp

The Server is IIS 6
Back to Top View gsp's Profile Search for other posts by gsp
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10520
Posted: 11 January 2011 at 6:01am | IP Logged Quote Anton

The rules should be:

[ISAPI_Rewrite]
RewriteCond Host: (?!www\..*)(.+\.com)
RewriteRule (.*) http\://www.$1$2 [RP]

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


Joined: 11 January 2011
Online Status: Offline
Posts: 25
Posted: 11 January 2011 at 6:24am | IP Logged Quote gsp

Thank You for the reply

I placed these lines on the top of my httpd.ini file and checked but it is not working

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


Joined: 11 January 2011
Online Status: Offline
Posts: 25
Posted: 11 January 2011 at 6:34am | IP Logged Quote gsp

After placing the code my httpd.ini file will be as below

[ISAPI_Rewrite]

RewriteCond Host: (?!www\..*)(.+\.com)
RewriteRule (.*) http\://www.$1$2 [RP]

### subdomain redirect v2 ###
RewriteCond Host: (?:.+\.)?subdomain1\.maindomain\.com
RewriteCond URL ^/subdomain1/(.*)
RewriteCond METHOD GET
RewriteRule ^/subdomain1/(.*) /$1 [I,R]
RewriteCond Host: (?:.+\.)?subdomain1\.maindomain\.com
RewriteCond METHOD POST
RewriteRule ^/subdomain1/(.*) /$1
RewriteCond Host: (?:.+\.)?subdomain1\.maindomain\.com
RewriteRule (.*) /subdomain1/$1 [I,L]

### subdomain redirect v2 ###
RewriteCond Host: (?:.+\.)?subdomain2\.com
RewriteCond URL ^/subdomain2/(.*)
RewriteCond METHOD GET
RewriteRule ^/subdomain2/(.*) /$1 [I,R]
RewriteCond Host: (?:.+\.)?subdomain2\.com
RewriteCond METHOD POST
RewriteRule ^/subdomain2/(.*) /$1
RewriteCond Host: (?:.+\.)?subdomain2\.com
RewriteRule (.*) /subdomain2/$1 [I,L]

### subdomain redirect v2 ###
RewriteCond Host: (?:.+\.)?subdomain3\.com
RewriteCond URL ^/subdomain3/(.*)
RewriteCond METHOD GET
RewriteRule ^/subdomain3/(.*) /$1 [I,R]
RewriteCond Host: (?:.+\.)?subdomain3\.com
RewriteCond METHOD POST
RewriteRule ^/subdomain3/(.*) /$1
RewriteCond Host: (?:.+\.)?subdomain3\.com
RewriteRule (.*) /subdomain3/$1 [I,L]

### subdomain redirect v2 ###
RewriteCond Host: (?:.+\.)?subdomain5\.org
RewriteCond URL ^/subdomain5/(.*)
RewriteCond METHOD GET
RewriteRule ^/subdomain5/(.*) /$1 [I,R]
RewriteCond Host: (?:.+\.)?subdomain5\.org
RewriteCond METHOD POST
RewriteRule ^/subdomain5/(.*) /$1
RewriteCond Host: (?:.+\.)?subdomain5\.org
RewriteRule (.*) /subdomain5/$1 [I,L]

### subdomain redirect v2 ###
RewriteCond Host: (?:.+\.)?subdomain4\.com
RewriteCond URL ^/subdomain4/(.*)
RewriteCond METHOD GET
RewriteRule ^/subdomain4/(.*) /$1 [I,R]
RewriteCond Host: (?:.+\.)?subdomain4\.com
RewriteCond METHOD POST
RewriteRule ^/subdomain4/(.*) /$1
RewriteCond Host: (?:.+\.)?subdomain4\.com
RewriteRule (.*) /subdomain4/$1 [I,L]

### subdomain redirect v2 ###
RewriteCond Host: (?:.+\.)?subdomain1\.in
RewriteCond URL ^/subdomain1/(.*)
RewriteCond METHOD GET
RewriteRule ^/subdomain1/(.*) /$1 [I,R]
RewriteCond Host: (?:.+\.)?subdomain1\.in
RewriteCond METHOD POST
RewriteRule ^/subdomain1/(.*) /$1
RewriteCond Host: (?:.+\.)?subdomain1\.in
RewriteRule (.*) /subdomain1/$1 [I,L]



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


Joined: 11 January 2011
Online Status: Offline
Posts: 25
Posted: 11 January 2011 at 6:35am | IP Logged Quote gsp

But this is not working, Please advice
Back to Top View gsp's Profile Search for other posts by gsp
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10520
Posted: 11 January 2011 at 7:27am | IP Logged Quote Anton

Can't see any reason for it to fail.
What is the request you are testing?

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


Joined: 11 January 2011
Online Status: Offline
Posts: 25
Posted: 11 January 2011 at 9:59pm | IP Logged Quote gsp

I need to do the following

Domain                               To be directed to
http://maindomain.com          http://www.maindomain.com
http://subdomain1.in             http://www.subdomain1.in


Thanks in advance




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


Joined: 11 January 2011
Online Status: Offline
Posts: 25
Posted: 12 January 2011 at 1:05am | IP Logged Quote gsp

Thanks a bunch for your help

I have included the below code  at the top.

RewriteCond Host: (?!www\..*)(.+\.in)
RewriteRule (.*) http\://www.$1$2 [RP]

RewriteCond Host: (?!www\..*)(.+\.com)
RewriteRule (.*) http\://www.$1$2 [RP]

RewriteCond Host: (?!www\..*)(.+\.org)
RewriteRule (.*) http\://www.$1$2 [RP]

Now the redirection is working fine for all sub domains. For maindomain alone it is not working that is
http://maindomain.com is not directing to      http://www.maindomain.com

Please advice,

Thanks in advance
Back to Top View gsp's Profile Search for other posts by gsp
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10520
Posted: 12 January 2011 at 3:21am | IP Logged Quote Anton

First, please make sure any ISAPI_Rewrite rules work for the maindomain.
Then please check for double registration of ISAPI_Rewrite filter (it must be registered globally).
And also check NTFS permissions.

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


Joined: 11 January 2011
Online Status: Offline
Posts: 25
Posted: 12 January 2011 at 3:51am | IP Logged Quote gsp

Thanks. I will check
Back to Top View gsp's Profile Search for other posts by gsp
 
gsp
Newbie
Newbie


Joined: 11 January 2011
Online Status: Offline
Posts: 25
Posted: 12 January 2011 at 4:54am | IP Logged Quote gsp

The redirection is working fine now. The problem is with our internal server.

Actually we were auditing our sites in http://www.aboutus.org

Thanks a lot for your help
Back to Top View gsp's Profile Search for other posts by gsp
 

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