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
1 Answer
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. :)
4 Comments
anubhava
First rule is not required and 2nd one should be:
RewriteRule ^questions/([^/]+)/?$ http://$1.mydomain.com/ [NC,R=301,L]Sunny R Gupta
Hmm, I get you. Modified.
sdsp
thanks, but does not works! i also have enabled wildcard subdomains in my webhost, and added *.mydomain.com in my host subdomain and also my domain dns panel. do you have any tips!?
Sunny R Gupta
Yes you need to add one more line to enable it for non www URLs. I've edited it accordingly. Let me know if it solves the problem.