有条件的 URL 重写

发布于 2024-08-22 02:42:38 字数 219 浏览 3 评论 0原文

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

示例:

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

How can I use URL rewriting in .htaccess to redirect to different domains depending on the URL?

Examples:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

护你周全 2024-08-29 02:42:38

如果您想重定向客户端,这应该可行:

# 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。

This ought to work if you want to redirect the client:

# 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]

If you prefer to proxy the requests, change the R flag to a P instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文