想要http://test.domain.tld/转到http://domain.tld/test [复制]

Possible Duplicate:
Internal subdomain to folder redirect

I want it to be automatic as I am making this for a URL shortener. I know how to make each one manually, but that won't work for what I need. I know I need something in .htaccess, but I am not experienced with that at all. Does anyone know what to add to get this working?

You can do it using apache mod_rewrite in .htaccess like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^\.]+).domain.tld$ [NC]
RewriteRule . http://domain.tld/%1 [R=301,L]

You can use mod_rewrite in your .htaccess file. Use regular expressions to define the redirect rule. Such as:

RewriteEngine On
RewriteRule ^(.+)\.domain\.tld /$1