将除部分内容之外的所有内容重定向到新 URL?
我正在移动网站,并且想对除部分 URL 之外的所有 URL 进行 301 重定向,
如下所示:
oldsite.com/*
-> www.newsite.com
oldsite.com/special/article/to/redirect
-> www.newsite.com/fancy/blah
因此,我想将一些内容重定向到特定页面,但其余所有内容都应该转到根目录,这如何在 .htaccess 中完成?
I am moving site and I want to do a 301 redirect on all but some of the URLs,
Like this:
oldsite.com/*
-> www.newsite.com
oldsite.com/specific/article/to/redirect
-> www.newsite.com/fancy/blah
So there are a few things I want to redirect to specific pages but all the rest should just goto root, how can this be done in .htaccess?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将以下内容添加到旧网站根目录中的
.htaccess
文件中。Add the following to the
.htaccess
file in the root directory of your old site.如果您只有一个需要豁免的 URL,可以使用 RedirectMatch。
对于多个 URL,您可能最好使用 mod_rewrite 和外部 rewritemap 列出了要豁免的网址。
There's RedirectMatch if you've got only one URL that needs to be exempted.
for multiple URLs, you'd probably be better off with mod_rewrite and an external rewritemap that lists the urls to be exempted.