On Wed, 09 Mar 2005 19:49:27 +0100,
Mark <mark_fink@web.de> posted:
> I tried this also in the virtual host section but I do not want to make
> it more difficult so I moved it into the .htaccess file.
So long as you're aware that some things can't be done in .htaccess files,
though this doesn't seem to be one of them.
> Problem:
> I have two domains www.mark-fink.de and www.mark-fink.com. Now I want to
> enforce the use of www.mark-fink.de all others (mark-fink.com ...)
> should be directed to this url. I set the aliases in the virtual host I
> use section (file since I use debian sarge).
>
> the .htaccess file looks like this:
> # Force usage of www.mark-fink.de
> RewriteCond %{HTTP_HOST} !^www\.mark-fink\.de [NC]
> RewriteCond %{HTTP_HOST} !^$
> RewriteRule ^/(.*) http://www.mark-fink.de/$1 [L,R]
The example I followed looked like this, and that sort of thing does work
for me:
RewriteCond %{HTTP_HOST} ^mark-fink.de$ [NC]
RewriteRule ^(.*)$ http://www.mark-fink.de/$1 [R=301,L]
I haven't tried it with the !^www\, not variation, but you can.
Note the "R=301", that makes the redirect a permanent redirect, rather than
a temporary one. i.e. All future references should use the new URI, and
bookmarks and databases using the old ones should be updated.
Without that, things like search engines will continue to use the URI that
you don't want them to.
Should your RewriteEngine on directive be nearer the top of the .htaccess
file?
--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.
This message was sent without a virus, please delete some files yourself.