.htaccess 如何从某些规则中排除一组特定的文件?

.htaccess 如何从某些规则中排除一组特定的文件?,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我正试图将我网站上的URL从.php重写为.html,我还有一些其他规则干扰了我想做的事情 下面的代码显示了所有的规则,但我有一些平面PHP页面,我想转换成.html页面。例如history.php到history.html Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / ##Vendor Pages RewriteRule ^([^/]+)/([^/]+)/([

我正试图将我网站上的URL从.php重写为.html,我还有一些其他规则干扰了我想做的事情

下面的代码显示了所有的规则,但我有一些平面PHP页面,我想转换成.html页面。例如history.php到history.html

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /


##Vendor Pages
RewriteRule ^([^/]+)/([^/]+)/([^.]+)\.html?$ vendors2.php?vendorslug=$3&locationslug=$1&categoryslug=$2 [L,QSA,NC]

##Listing Pages
RewriteRule ^([^/]+)/([^.]+)\.html?$ listings.php?locationslug=$1&categoryslug=$2 [L,QSA,NC]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !^(.*/)?history\.html$ [NC]
RewriteRule ^([^/.]+)\.html?$ $1.php [L,NC]

##Locations Pages
RewriteRule ^([^/.]+)\.html?$ locations.php?locationslug=$1&Submit=Submit [L,QSA,NC]
目前,代码似乎与其他规则混淆,因为它正试图根据规则将页面作为“位置页面”返回

我需要将几个页面转换为.html(history.php、news.php、maps.php、resources.php、trivia.php和其他页面)


非常感谢您提供的任何建设性帮助。

您可能根本不符合重写条件。检查文件是否存在的
RewriteCond
很可能被解释为“是
/home/username/public\u html/history.html.php
文件吗?”,这将失败

我建议您不要在规则之前包含几个
RewriteCond
,而可以在
#Locations页面
之前使用一个
RewriteRule
。如下所示:

RewriteRule (history|news|maps|resources)\.html $1.php [L]
请注意,如果您有很多条目,这可能会产生一个looong行,因此您可以将其拆分为几个规则

如果您正在“根目录”中查找请求:


我建议你打开重写日志…arkascha,谢谢你的提示。我还没有尝试重写日志记录。我会仔细阅读并用它做实验。再次感谢。这正是我所需要的。非常感谢你!我感谢你的帮助。
RewriteRule ^(history|news|maps|resources)\.html$ $1.php [L]