Welcome Guest, Not a member yet? Register   Sign In
[Solved]: Gonna loose my job today !!! default controller redirecting url http://domain.com to http://www.domain.com. Wh
#4

[eluser]John_Betong[/eluser]
Hi Sarfaraz Momin,

Take a look at this site, it has quite a few good examples which I believe will solve your problem:

http://www.sitepoint.com/article/apache-...examples/2
Quote:1. Forcing www for a domain while preserving subdomains

RewriteCond %{HTTP_HOST} ^([a-z.]+)?example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.xample.com%{REQUEST_URI} [R=301,L]

This rule captures the optional subdomain using the %1 variable, and, if it doesn't start with www., redirects with www. prepended to the subdomain. The domain and the original {REQUEST_URI} are appended to the result.

2. Eliminating www from a domain

RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule .? http://example.com%{REQUEST_URI} [R=301,L]

Don't forget to let us know if you find a solution.

Cheers,

John_Betong
 


Messages In This Thread
[Solved]: Gonna loose my job today !!! default controller redirecting url http://domain.com to http://www.domain.com. Wh - by El Forum - 09-29-2007, 03:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB