Afficher un message
Vieux 26/02/2005, 14h04   #3
LJM
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: htaccess q: preventing www at beginning of address

Friends, David Efflandt, countrymen, lend me your newsreaders:
> On 25 Feb 2005 18:08:29 GMT, LJM <subtextwhore@gmail.com> wrote:
>> My WPP has somehow configured the (Unix) webserver to prefix the URL
>> with a www. if there is no trailing slash (/) at the end of the URL.
>>
>> eg. http://myurl.com/test/ is left untouched but
>> http://myurl.com/test is changed to
>> http://www.myurl.com/test/ ...which causes all further links to be
>> prefixed with www.
>>
>> I want to stop this. Is there anything I could put in .htaccess to just
>> put a trailing slash on the end, but prevent the www being prefixed?

>
> Read apache docs for UseCanonicalName. But you may not be able to set
> that off in .htaccess, because it says Context: server config, virtual
> host, directory, but virtual host and directory can only be done in server
> config. So your web host would need to change that (possibly within your
> VirtualHost section if a virtual host).


It was actually leaving the URL alone unless a directory was specified
without a trailing slash. In adding the slash, it also added the www.
at the beginning of the URL. I figured the following RewriteRule would
fix it:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.mydomain\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://mydomain.co.uk/$1 [R=301,L]

I don't think that will cause problems elsewhere.
--
Lee J. Moore
"Life is short, art is long."
  Réponse avec citation
 
Page generated in 0,05766 seconds with 9 queries