[Wylug-help] Fwd: Re: Fwd: Re: Apache .htaccess file.

Stephen Patterson steve at patter.me.uk
Mon Oct 19 11:13:30 UTC 2009


John Craven wrote:
> Hi Smylers..
>
> Unfortunately I'm thick.
> I don't fully understand all the code that's in the script.
> I checked on http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html and it put me in the right direction.
> Then I just applied the code and checked if it worked.
>
> John C
>
>   
>> John Craven writes:
>>
>>     
>>> I have been doing some experimenting to test your requirements and
>>> this code works for me:
>>>
>>> # redirect any URLs that don't have "www."
>>> RewriteCond %{HTTP_HOST} !^www\.countrymusic\.org\.uk [NC]  
>>> RewriteCond %{HTTP_HOST} !^$  
>>> RewriteRule ^/?(.*)         http://www.countrymusic.org.uk/$1 [L,R,NE]
>>>       
>> Ah, I wonder if that question mark after the slash is what Doug needs.
>> Possibly without it http://countrymusic.org.uk (without a trailing
>> slash) wouldn't match.
>>     
Hope I'm not providing even more confusion, but these 4 lines work for
me. Check that you've also got RewriteBase set appropriately.

    RewriteEngine on
    RewriteBase   /
    RewriteCond %{HTTP_HOST}  !www.patter.me.uk
    RewriteRule ^.*$     http://www.patter.me.uk%{REQUEST_URI} [R=301]



More information about the Wylug-help mailing list