This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Subdomain rule help please
Author
Message |
darka
Newbie


Joined: 13 March 2008
Posts: 12
Posted: 04 January 2012 at 4:44pm

Hi Guys,

I have the following rules which redirect http://beta. and http://upload. to: mydomain.com. The 3rd rule adds the "www" to the address (for example:www.mydomain.com) if it is not present.

Rules:

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?:beta\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://%2%3 [R=301,L]

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?:upload\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://%2%3 [R=301,L]

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

Now the problem I have is that I want the following url to NOT add the 'www' to the beginning.

http://static.mydomain.com/js/file.js

At the moment because of the 3rd rule the www is changing the above rule to redirect to:

http://www.static.mydomain.com/js/file.js

which is incorrect.

Ive been pulling my hair out over this. I must keep the rule which adds the www by the way.

Thanks for any help / the correct rules.

Cheers



 


Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 05 January 2012 at 5:05am

Hello,

Try using smth like:

Code:
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!(?:www|beta|upload)\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]


Regards
Andrew
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version