Skip navigation.

极湖

无不用其“极”

Posts tagged with "mod_rewrite"

实现域名重定向的 Rewrite 写法

, ,

一. http(默认 80 端口)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain2.com
RewriteRule ^(.*)$ http://domain1.com/$1 [R,L]


二. https(默认 443 端口)
写法一:
RewriteCond %{HTTP_HOST} ^domain2.com
RewriteCond %{HTTPS} ^on$
RewriteRule ^(.*)$ https://domain1.com/$1 [R,L]


写法二:
RewriteCond %{HTTP_HOST} ^domain2.com
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ https://domain1.com/$1 [R,L]


三. http + https(所有端口)
RewriteCond %{HTTP_HOST}   ^domain2.com
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^(.*)$         http://domain1.com:%{SERVER_PORT}/$1 [L,R]
RewriteCond %{HTTP_HOST}   ^domain2.com
RewriteRule ^(.*)$         http://domain1.com/$1 [L,R]
December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31