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: non-www to www using isapi_rewrite
Author
Message |
gsp
Newbie


Joined: 11 January 2011
Posts: 25
Posted: 11 January 2011 at 5:26am

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
 
gsp
Newbie


Joined: 11 January 2011
Posts: 25
Posted: 11 January 2011 at 5:38am

The Server is IIS 6
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 11 January 2011 at 6:01am

The rules should be:

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

__________________
Regards,
Anton
Back to Top
 
gsp
Newbie


Joined: 11 January 2011
Posts: 25
Posted: 11 January 2011 at 6:24am

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
 
gsp
Newbie


Joined: 11 January 2011
Posts: 25
Posted: 11 January 2011 at 6:34am

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
 
gsp
Newbie


Joined: 11 January 2011
Posts: 25
Posted: 11 January 2011 at 6:35am

But this is not working, Please advice
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 11 January 2011 at 7:27am

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

__________________
Regards,
Anton
Back to Top
 
gsp
Newbie


Joined: 11 January 2011
Posts: 25
Posted: 11 January 2011 at 9:59pm

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
 
gsp
Newbie


Joined: 11 January 2011
Posts: 25
Posted: 12 January 2011 at 1:05am

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
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 12 January 2011 at 3:21am

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
 
gsp
Newbie


Joined: 11 January 2011
Posts: 25
Posted: 12 January 2011 at 3:51am

Thanks. I will check
Back to Top
 
gsp
Newbie


Joined: 11 January 2011
Posts: 25
Posted: 12 January 2011 at 4:54am

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
 

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