0

A website of mine is accessible through different URL:

studienbuch.ch
studienbuch.at
studienbuch.com

I'd like to have them changed to www.studienbuch.tld, but keep the top level domain:

studienbuch.ch -> www.studienbuch.ch
studienbuch.at -> www.studienbuch.at
studienbuch.com -> www.studienbuch.com

How to handle that with .htaccess?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Lionel
  • 1,949
  • 3
  • 17
  • 27

2 Answers2

1

The following should work (untested):

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.studienbuch\.(ch|at|com)
RewriteRule ^(.*)$ http://www.studienbuch.%1/$1 [R=301,L]
Ben
  • 3,922
  • 1
  • 22
  • 21
  • Thank you for your answer, but it's unfortunately not yet doing the trick. It forwards the page to "www.studienbuch." without adding the top level domain. – Lionel Dec 14 '10 at 07:48
1

Try

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.  [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1  [R=301,L]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220