条件URL重写

时间:2010-02-20 08:26:40

标签: mod-rewrite

如何在.htaccess中使用网址重写根据网址重定向到不同的域?

示例:

  • http://ONE/http://TWO/
  • http://ONE/some_contenthttp://THREE/some_content

1 个答案:

答案 0 :(得分:2)

如果您想重定向客户端,这应该有效:

# http://ONE/ to http://TWO/
RewriteCond %{HTTP_HOST}    =one
RewriteRule ^$             http://two/ [R,L]

# http://ONE/some_content to http://THREE/some_content
RewriteCond %{HTTP_HOST}    =one
RewriteRule ^(.+)$         http://three/$1 [R,L]

如果您希望代理请求,请将R标志更改为P.