Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

url rewriting - Rewrite sub-domain to directory

I'd like to map subdomain.example.com to www.example.com/subdomain using an internal URL rewrite that looks at the host name and simply forwards any request to a subdirectory with the same name as the subdomain.

Thanks for your help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using .htaccess:

RewriteCond %{HTTP_HOST} !^www.yourdomain.com 
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...