In article <[EMAIL PROTECTED]>, Jim Seymour <[EMAIL PROTECTED]> wrote:
> Hi All, > > Running Apache 2.2 on Debian testing and having no luck getting a > rewrite rule to work. Straight out of the rewrite guide I am trying the > following to force the domain name to always be displayed as > www.domain.com even when it is accessed as domain.com. > > RewriteEngine on > RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] > RewriteCond %{HTTP_HOST} !^$ > RewriteRule ^/(.*) http://www.domain.com/$1 [L,R] > > I have tried many variations of this rule in both the apache virtual > configuration as well as an .htaccess file. I have verified via a dump > of the modules loaded that the rewrite module is loaded. The Options > FollowSymLinks is set and AllowOverride is set to FileInfo. I know the > .htaccess file is being read because I can put trash in it and it will > result in an Internal Server Error. Once the garbage is removed I can > load the web page without error. The rewrite rule never has an effect > and never gives any errors. Ideas? I am not sure if this helps as I do the opposite, i.e. change all www.domain.com requests to domain.com. I do it two ways. On my own Apache server I do it this way: <VirtualHost *> DocumentRoot /srv/www/htdocs/domain.com ServerName domain.com </VirtualHost> <VirtualHost *> DocumentRoot /srv/www/htdocs/domain.com ServerName www.domain.com Redirect / http://domain.com/ </VirtualHost> and on a paid for hosting account using Rewrite (in a .htaccess file) this also works, but, again, to do the opposite of what you want: RewriteEngine on rewritecond %{http_host} ^www\.domain\.com [nc] rewriterule ^(.*)$ http://domain.com/$1 [r=301,nc] -- Bob Cox. Stoke Gifford, near Bristol, UK. http://pippin.co.uk/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]