Forum Moderators: phranque
I would like to redirect all subdomain to related folder with 302 redirect. I have complete access to web server (root account) and I can modify everithyng into Apache config and .htaccess.
So i need to do it:
[xyz.example.com...] ===> http://www.example.com/xyz/
where "xyz" is everything but not www.
How can do that ?
At the moment I can do only this:
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Redirect 301 from example.com to www.example.com.
Can anyone help me please ?
Thanks and good day to everybody,
Leonardo
[edited by: jdMorgan at 11:24 pm (utc) on June 10, 2008]
[edit reason] example.com [/edit]
still nothing....
[edited by: jdMorgan at 11:26 pm (utc) on June 10, 2008]
[edit reason] example.com [/edit]
Where IPADDRESS is the IP of your server.
Into the Virtual Host add this lines:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+).example.com
RewriteRule ^(.*) http://www.example.com/%1/ [R=302,L]
Now everything works fine.
Thanks,
Leonardo
[edited by: jdMorgan at 11:25 pm (utc) on June 10, 2008]
[edit reason] example.com [/edit]
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com
RewriteRule ^/(.*)$ /%1/ [L]
Jim