Php htaccess重定向除两个URL之外的所有URL

Php htaccess重定向除两个URL之外的所有URL,php,.htaccess,Php,.htaccess,目前我正在将所有URL重定向到我的index.html文件: RewriteEngine on RewriteCond %{REQUEST_URI} !^/index.html$ RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$ RewriteRule .* /index.html [L,R=302] 我想排除两个URL,例如: www.mydomain.com/i-am-a-domain www.mydomain.com/super-

目前我正在将所有URL重定向到我的
index.html
文件:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* /index.html [L,R=302]
我想排除两个URL,例如:

www.mydomain.com/i-am-a-domain
www.mydomain.com/super-cool
我找到了几个代码片段来排除URL,但我无法包含它们,因为它们使用不同的设置(至少我认为是这样)

由于
RewriteCond
设置了条件,我想我必须在这里添加一行。我尝试补充:

RewriteCond %{REQUEST_URI} !/(i-am-a-domain|super-cool)\ [NC]

这是行不通的。我如何才能做到这一点?

将您现有的条件更改为:

RewriteEngine on

RewriteCond %{REQUEST_URI} !^/(index\.html|i-am-a-domain|super-cool)/?$ [NC]
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule ^ /index.html [L,R=302]
但是,如果在这个.htaccess中还有其他规则,那么我建议使用
这个变量,在执行一些内部重写规则后,该变量不会被覆盖

RewriteCond %{THE_REQUEST} !\s/+(index\.html|i-am-a-domain|super-cool)[?\s/] [NC]
RewriteCond %{THE_REQUEST} !\.(gif|jpe?g|png|css|js)\sHTTP
RewriteRule ^ /index.html [L,R=302]