Pregunta

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

¿Fue útil?

Solución

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]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top