Try this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteRule . - [S=2]
RewriteRule ^subdomain/(.+)$ http://subdomain.domain.com/$1 [R=301,L]
RewriteRule ^subdomain/?$ http://subdomain.domain.com [R=301,L]
Question
I'm attempting to do a subdomain rewrite for apache using a .htaccess file.
Currently: domain.com/subdomain
Desired result: subdomain.domain.com
This is what I have so far...
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
RewriteRule ^subdomain/(.*)$ http://www.domain.com/$1 [R=301,L]
Any help would be great appreciated!
Cheers, Wayne
Solution
Try this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteRule . - [S=2]
RewriteRule ^subdomain/(.+)$ http://subdomain.domain.com/$1 [R=301,L]
RewriteRule ^subdomain/?$ http://subdomain.domain.com [R=301,L]