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

Categories

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

.htaccess - Rewrite folder to subdomain

I want to rewrite all addresses after this
http://www.mydomain.com/questions/*
to this
http://*.mydomain.com/
for example:
http://www.mydomain.com/questions/example
http://example.mydomain.com/
Can anyone help me in this issue!?
Thanks

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

There you go.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^.mydomain.com$
RewriteRule ^questions/([^/]+)/?$ http://$1.mydomain.com/ [NC,R=301,L]

Plug this into your .htaccess file and you should be good to go. :)


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