Re: Trouble With mod_rewrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2008-09-16 at 07:01 -0700, Drew Tomlinson wrote:
> Ben Spencer wrote:
> > Looks like you went the wrong direction with the rewrite. The ! is "not".
> > You have "not" www.consumer-sc.ca.gov, then redirect.
> >
> > RewriteCond %{HTTP_HOST}   !^www\.consumer-sc\.ca\.gov$ [NC]
> >
> > Should be
> >
> > RewriteCond %{HTTP_HOST}   ^www\.consumer-sc\.ca\.gov$ [NC]
> >
> > Or even (which doesn't force the requirement of "www")
> >
> > RewriteCond %{HTTP_HOST}   consumer-sc\.ca\.gov$ [NC]
> >   
> 
> Thank you very much!  That was it.
> 
> Drew
> 

Whilst that is absolutely correct, I think the 'correct' (nothing is
ever correct) logic is that you wish all requests to be served from (eg)
www.mainsite.com, rather than sub.mainsite.com or mainsite.com (or any
other ServerAlias). Hence, I'd write the rule as:

RewriteCond %{HTTP_HOST} !^www\.mainsite\.com$ [NC]
RewriteRule ^/(.*) http://www.mainsite.com/$1 [R=301,L]

Cheers

Tom


Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux