Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除php/html扩展名并从规则中排除一个特定文件_Php_.htaccess_Url - Fatal编程技术网

删除php/html扩展名并从规则中排除一个特定文件

删除php/html扩展名并从规则中排除一个特定文件,php,.htaccess,url,Php,.htaccess,Url,我的.htaccess规则从URL中删除所有.html和.php扩展名 但是,我需要从该规则中排除一个特定的.php文件,例如文件mailscript/sendmail.php 在我现在拥有的当前规则配置上,这怎么可能呢 .htaccess AddType text/html .shtml AddHandler server-parsed .shtml Options Indexes FollowSymLinks Includes AddHandler server-parsed .html .

我的
.htaccess
规则从URL中删除所有
.html
.php
扩展名

但是,我需要从该规则中排除一个特定的
.php
文件,例如文件
mailscript/sendmail.php

在我现在拥有的当前规则配置上,这怎么可能呢

.htaccess

AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
AddHandler server-parsed .html .htm

RewriteEngine on

RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]

RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]

我试图应用基于
的重写规则^sendmail\.php$[L]
,但它不适用于我当前的规则。

您可以将此规则添加到跳过
sendmail.php

RewriteRule (?:^|/)sendmail\.php$ - [L,NC]
在行的
重写引擎下方添加此规则