.htaccess:将所有请求转发到另一个站点
我必须将现有网站转发到另一个网站。
我想将旧网站上的每个请求转发到新网站的根目录。
示例:http://oldsite.tld/index.php?mode=foo&action=bar
应转发到 http://newsite.tld/
而不转发 http://newsite.tld/index.php?mode=foo&action=bar
。
单独使用 .htaccess 可以吗?我也有可能使用 PHP。
谢谢。
I have to forward an existing website to another one.
I want to forward each and every request on the old site to the root of the new site.
Example:http://oldsite.tld/index.php?mode=foo&action=bar
should be forwarded to http://newsite.tld/
and not http://newsite.tld/index.php?mode=foo&action=bar
.
Is this possible with .htaccess alone? I'd also have the possibility of using PHP.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我决定使用 mod_rewrite 来实现,.htaccess 中的一个简单的
Redirect
并不能完全完成这项工作。以下是我最终使用的内容:
URL 末尾的
?
确保忽略所有查询。Okay, I decided to do it with mod_rewrite, a simple
Redirect
in the .htaccess didn't quite do the job.Here's what I ended up using:
The
?
at the end of the URL makes sure all queries are ignored.只需在每个文件的顶部放置
对所有
.php
文件运行快速前置操作。Simply on the top of every file put
Run a quick prepend operation on all
.php
files.