문제

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

도움이 되었습니까?

해결책

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top