mod_rewrite to capture subdomain name

Posted by Ricky on Server Fault See other posts from Server Fault or by Ricky
Published on 2010-05-24T23:45:05Z Indexed on 2010/05/24 23:51 UTC
Read the original article Hit count: 500

Filed under:
|
|

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

vise versa

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? thank you.

© Server Fault or respective owner

Related posts about apache

Related posts about mod-rewrite