htaccess 301 重定向整个网站,但有例外
我正在尝试创建一个 htaccess 文件来重定向我的整个网站(除了一些例外),但我无法让它工作。我需要重定向整个内容,提供特定的重定向,并排除两个页面。以下是我的非工作示例。谢谢!
RewriteCond %{REQUEST_URI} !^/events/index.html
RewriteCond %{REQUEST_URI} !^/calendar/index.html
Redirect 301 /info/faq.html http://mynewsite.com/my-page
Redirect 301 / http://mynewsite.com
I am trying to create an htaccess file to redirect my entire site except with some exceptions, but I can't get it working. I need to redirect the entire thing, provide a specific redirect, and exclude two pages. Below is my non-working sample. Thanks!
RewriteCond %{REQUEST_URI} !^/events/index.html
RewriteCond %{REQUEST_URI} !^/calendar/index.html
Redirect 301 /info/faq.html http://mynewsite.com/my-page
Redirect 301 / http://mynewsite.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尝试将
mod_rewrite
与mod_alias
混合使用,但RewriteCond
语句无法调节Redirect
语句,因为它们不是来自同一个模块。如果我正确理解了您想要实现的目标,我相信您想要更多类似的东西:
You're attempting to mix
mod_rewrite
withmod_alias
, but theRewriteCond
statements cannot condition theRedirect
statements, as they don't come from the same module.I believe you want something more like this, if I've correctly understood what you were trying to accomplish:
我有类似的问题。尝试重定向整个域(robots.txt 文件除外)。蒂姆的回答对我不起作用,但这确实有效
I had a similar issue. Trying to redirect an entire domain with the exception of its robots.txt file. Tim's answer didn't work for me, but this did