重定向到新域页面而不更改旧域名

发布于 2025-02-04 00:25:51 字数 387 浏览 4 评论 0 原文

我有两个不同的域olddomain.com和newdomain.com。所有工作页面仅在旧域中。新域中只有一页,因此,当他们单击新域/subpageUrl内容时,应从newdomain/subpage中显示,但url应该是worddomain.com/subpage

newdomain.com/subpage1 - > olddomain.com/subpage1,

但URL应该喜欢olddomain.com/subpage1

我尝试过。

RewriteEngine On
RewriteCond %{HTTP_HOST} olddomain.com$
RewriteRule (.*) http://newdomain.com/$1 [R=301,L]

I have two different domains olddomain.com and newdomain.com .All working pages are in olddomain only. Only one page in new domain So,when they click on newdomain/subpageurl content should display from newdomain/subpage but url should be olddomain.com/subpage

newdomain.com/subpage1 -->olddomain.com/subpage1

But URL should be like olddomain.com/subpage1

I tried this..

RewriteEngine On
RewriteCond %{HTTP_HOST} olddomain.com$
RewriteRule (.*) http://newdomain.com/$1 [R=301,L]

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

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

发布评论

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

评论(2

岁月静好 2025-02-11 00:25:51

首先,您必须将新的域页面文件放入旧域。在旧域根文件夹中制作一个子文件夹。然后将文件上传到子文件夹中。喜欢
olddomain.com/subfolder/files

First, You have to put your new domain page file into the old domain. make a sub folder in your old domain root folder. then upload your file into the sub folder. Like
olddomain.com/subfolder/files

总攻大人 2025-02-11 00:25:51

您可能正在寻找一种在Olddomain转发请求中实现透明代理的方法。正如对问题的评论所说,您对此很含糊。

存在两个直接的选择。显然,这两种方法都要求将代理模块加载到Olddomain.com上的HTTP服务器中。更确切地说,代理 proxy_http模块。我假设您在这里使用Apache HTTP服务器为Olddomain.com提供服务...


使用重写模块,该模块能够使用内部代理模块:

RewriteEngine on
RewriteRule ^/?subpage/?$ https://newdomain.com/subpage [P]

文档: https://httpd.apache.org/docs/current/current/rewrite/rewrite/flags.html#flag_p


org/docs/current/rewrite/fraits.html#flag_p“ rel = “ 模块:

ProxyRequests off
ProxyPass /subpage https://newdomain.com/subpage
ProxyPassReverse  /subpage https://newdomain.com/subpage

文档:

是的,它是 proxyRequests Off and proxyrequests


这两种方法都适用于针对olddomain.com的请求( https://olddomain.com/subpage )。这将不是直接针对newdomain.com的请求的 。为此,您必须在newdomain.com上实现另一个指向olddomain.com的外部重定向。但是,这有点棘手,因为您必须注意 将通过OldComain.com上代理提出的那些请求重定向。因为那将导致重定向循环。

You are probably looking for a way to implement a transparent proxy inside olddomain forwarding requests to newdomain. As said in the comments to the question you are vague in that.

Two immediate alternatives exist. Both approaches require the proxy module to be loaded into the http server on olddomain.com, obviously. More precisely the proxy and the proxy_http module. I assume here that you are using the apache http server to serve olddomain.com ...


Using the rewrite module, which is able to use the internal proxy module:

RewriteEngine on
RewriteRule ^/?subpage/?$ https://newdomain.com/subpage [P]

The documentation: https://httpd.apache.org/docs/current/rewrite/flags.html#flag_p


Directly using the proxy module:

ProxyRequests off
ProxyPass /subpage https://newdomain.com/subpage
ProxyPassReverse  /subpage https://newdomain.com/subpage

Documentation: https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass

And yes, it is ProxyRequests off and not ProxyRequests on.


Both approaches work for requests targeting olddomain.com (https://olddomain.com/subpage). This will not work for requests directly targeting newdomain.com. For that you would have to implement an additional external redirection in newdomain.com pointing to olddomain.com. That is a bit tricky however since you have to take care to not redirect those requests that came through the proxy on oldcomain.com. Because that would lead to a redirection loop.

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