重定向到新域页面而不更改旧域名
我有两个不同的域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]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您必须将新的域页面文件放入旧域。在旧域根文件夹中制作一个子文件夹。然后将文件上传到子文件夹中。喜欢
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
您可能正在寻找一种在Olddomain转发请求中实现透明代理的方法。正如对问题的评论所说,您对此很含糊。
存在两个直接的选择。显然,这两种方法都要求将代理模块加载到Olddomain.com上的HTTP服务器中。更确切地说,代理和 proxy_http模块。我假设您在这里使用Apache HTTP服务器为Olddomain.com提供服务...
使用重写模块,该模块能够使用内部代理模块:
文档: https://httpd.apache.org/docs/current/current/rewrite/rewrite/flags.html#flag_p
org/docs/current/rewrite/fraits.html#flag_p“ rel = “ 模块:
文档:
是的,它是
proxyRequests Off
andproxyrequests
。这两种方法都适用于针对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:
The documentation: https://httpd.apache.org/docs/current/rewrite/flags.html#flag_p
Directly using the proxy module:
Documentation: https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass
And yes, it is
ProxyRequests off
and notProxyRequests 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.