Apache 从规则中排除URL或模式

Apache 从规则中排除URL或模式,apache,.htaccess,rewrite,Apache,.htaccess,Rewrite,我想从规则中排除某些URL,但由于我对apache有绝对的了解,我似乎无法确定这些条件 RewriteEngine On RewriteCond %{HTTP:X_FORWARDED_PROTO} https #RewriteCond %{REQUEST_URI} !^/(account|checkout|login) RewriteCond %{REQUEST_URI} !/account/login.html RewriteCond %{REQUEST_URI} !/index.php?m

我想从规则中排除某些URL,但由于我对apache有绝对的了解,我似乎无法确定这些条件

RewriteEngine On
RewriteCond %{HTTP:X_FORWARDED_PROTO} https
#RewriteCond %{REQUEST_URI} !^/(account|checkout|login) 
RewriteCond %{REQUEST_URI} !/account/login.html
RewriteCond %{REQUEST_URI} !/index.php?main_page=password_forgotten
RewriteCond %{REQUEST_URI} !/account/
RewriteCond %{REQUEST_URI} !/account/edit.html
RewriteCond %{REQUEST_URI} !/account/address-book/
RewriteCond %{REQUEST_URI} !^/account/change-password.html
RewriteCond %{REQUEST_URI} !^/account/notifications/
RewriteCond %{REQUEST_URI} !^/index.php?main_page=checkout&fecaction=null
RewriteCond %{REQUEST_URI} !^/index.php?main_page=checkout_shipping_address
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
我认为应该有一种方法来排除所有包含/account/or=checkout的URL,但我不知道如何排除


还有人能解释一下,^、(.*)是什么吗?我认为它们是运算符,但我似乎找不到任何信息,现在没有时间学习apache。

所有这些奇怪的字符都是正则表达式的一部分。详情请参见此处

你可以省略所有这些

RewriteCond %{REQUEST_URI} !/account/login.html
RewriteCond %{REQUEST_URI} !/account/edit.html
RewriteCond %{REQUEST_URI} !/account/address-book/
RewriteCond %{REQUEST_URI} !^/account/change-password.html
RewriteCond %{REQUEST_URI} !^/account/notifications/
因为

RewriteCond %{REQUEST_URI} !/account/
已经涵盖了所有这些

=checkout
的测试不同,因为这不是URL路径的一部分,而是查询字符串的一部分。排除查询字符串中包含
=checkout
的每个请求

RewriteCond %{QUERY_STRING} !.=checkout

非常感谢,不幸的是,我认为我的问题出在规则的某个地方,因为这些修改不起作用,我也尝试只排除index.php,但没有结果。@user2173812您的
重写规则将
$1
替换为
$1
,所以这并不奇怪。除非有其他规则,否则显示的.htaccess是noop。