문제

I've used the following to redirect domain.tld and *.domain.tld to www.domain.tld (except subdomain dev.domain.tld). But this doesn't seem to work for domains containing a dash like dom-ain.tld. Why?

RewriteCond %{HTTP_HOST} !^[www|dev]\.* [NC]
RewriteRule ^(.*) http://www\.%{HTTP_HOST}/$1 [R=301]
도움이 되었습니까?

해결책

Your regex is actually incorrect.

Replace your rule with this:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(www|dev)\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top