htaccess 301重定向整个站点,但有例外 [英] htaccess 301 redirect entire site but with exceptions
问题描述
除某些例外,我正在尝试创建htaccess文件来重定向我的整个网站,但是我无法使其正常运行.我需要重定向整个内容,提供特定的重定向,并排除两个页面.以下是我无法正常工作的示例.谢谢!
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
推荐答案
您正在尝试将mod_rewrite
与mod_alias
混合使用,但是RewriteCond
语句不能对Redirect
语句进行条件设置,因为它们不会来自同一模块.
You're attempting to mix mod_rewrite
with mod_alias
, but the RewriteCond
statements cannot condition the Redirect
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:
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/events/index.html
RewriteCond %{REQUEST_URI} !=/calendar/index.html
RewriteCond %{REQUEST_URI} !=/info/faq.html
RewriteRule ^.*$ http://mynewsite.com/$0 [R=301,L]
Redirect 301 /info/faq.html http://mynewsite.com/my-page
这篇关于htaccess 301重定向整个站点,但有例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!