Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
918 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 OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...