| Author |
|
gsp Newbie

Joined: 11 January 2011
Online Status: Offline Posts: 25
|
| Posted: 11 January 2011 at 5:26am | IP Logged
|
|
|
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
Online Status: Offline Posts: 25
|
| Posted: 11 January 2011 at 5:38am | IP Logged
|
|
|
The Server is IIS 6
|
| Back to Top |
|
| |
Anton Admin Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 10520
|
| Posted: 11 January 2011 at 6:01am | IP Logged
|
|
|
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
Online Status: Offline Posts: 25
|
| Posted: 11 January 2011 at 6:24am | IP Logged
|
|
|
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
Online Status: Offline Posts: 25
|
| Posted: 11 January 2011 at 6:34am | IP Logged
|
|
|
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
Online Status: Offline Posts: 25
|
| Posted: 11 January 2011 at 6:35am | IP Logged
|
|
|
But this is not working, Please advice
|
| Back to Top |
|
| |
Anton Admin Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 10520
|
| Posted: 11 January 2011 at 7:27am | IP Logged
|
|
|
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
Online Status: Offline Posts: 25
|
| Posted: 11 January 2011 at 9:59pm | IP Logged
|
|
|
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
Online Status: Offline Posts: 25
|
| Posted: 12 January 2011 at 1:05am | IP Logged
|
|
|
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
Online Status: Offline Posts: 10520
|
| Posted: 12 January 2011 at 3:21am | IP Logged
|
|
|
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
Online Status: Offline Posts: 25
|
| Posted: 12 January 2011 at 3:51am | IP Logged
|
|
|
Thanks. I will check
|
| Back to Top |
|
| |
gsp Newbie

Joined: 11 January 2011
Online Status: Offline Posts: 25
|
| Posted: 12 January 2011 at 4:54am | IP Logged
|
|
|
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 |
|
| |