여러 도메인을 다루는 규칙을 만드는 것은 매우 간단합니다. 당신이 원하는 것을 달성하기 위해, 당신이 뭔가를 할 수 있습니다 :
이
RewriteCond %{HTTP_HOST} ^(www\.)?example\.(de|fr|co\.uk)$
RewriteRule .* http://www.example.com/?loc=%2 [R]
그것은 example.de
소요 요청으로 example.com/~loc=de
로 재 작성하고, .fr
및 .co.uk
에 대해서도 작동합니다. 그러나주의해야 할 점은 .co.uk
버전을 example.com/~loc=co.uk
으로 다시 작성한다는 것입니다. 또한 새 도메인을 위해 수정해야합니다.
그래서, 여기에 좀 더 일반적인입니다 솔루션은, 그러나 당신이 원하는 무엇을 달성해야합니다
이제 조금 설명
RewriteCond %{HTTP_HOST} ^(www\.)?example\.(co\.)?(.*)$
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$
RewriteRule .* http://example.com/?loc=%3 [R]
:
첫 번째 RewriteCond
이 같은 그것에 example
어떤 도메인과 일치 등 example.co.uk
, www.example.de
, www.example.xxx
로
는
제 RewriteCond
확실하게 그 HTTP_HOST 난 sn'texample.com
또는 www.example.com
.
마지막으로 RewriteRule
은 두 규칙과 일치하는 내용을 모두 다시 작성하고 도메인의 마지막 부분을 매개 변수로 마지막 부분에 고정합니다.
http://www.example.co.uk/
->http://example.com/?loc=uk
http://www.example.de/
->http://example.com/?loc=de
http://www.example.xxx/
->
http://www.example.com/
http://example.com/?loc=xxx
리디렉션하지 않습니다. 사용자가 http://www.example.de/some/path/index.php
에 가면 위의 솔루션, 경로가 리디렉션하지 않을 것이라고
는
참고. 이 기능을 원하면 리디렉션에 경로를 포함해야합니다.
RewriteRule (.*) http://example.com/$1?loc=%3 [R]