1

I want to write a rewrite scheme such that:

  • user1.example.net will redirect to example.net/user/user1
  • user2.example.net will redirect to example.net/user/user2

This is what I have in my .htaccess code. But it always redirects to example.net.

RewriteCond %{http_host} ^[^.]+\.example\.net [NC]
RewriteRule ^([^.]+)\.example\.net(.*) http://example.net/user/$1 [R=301,L]

Can someone please tell me what I did wrong?

1 Answer 1

1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.example.com [NC]
RewriteRule ^(.*)$ http://example.com/user/%1/$1 [R=301,L]

You must log in to answer this question.