3

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 1

3

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. :)

Sign up to request clarification or add additional context in comments.

4 Comments

First rule is not required and 2nd one should be: RewriteRule ^questions/([^/]+)/?$ http://$1.mydomain.com/ [NC,R=301,L]
Hmm, I get you. Modified.
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!?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.