Php 如何使用htaccess将除一个页面之外的所有页面重定向到索引页面

Php 如何使用htaccess将除一个页面之外的所有页面重定向到索引页面,php,apache,.htaccess,Php,Apache,.htaccess,目前,我的网站正在将所有扩展名为.php的页面重定向到Index.php页面 但是我不想在register.php页面上看到这个,请帮助我。下面是我正在做的 DirectoryIndex index.php Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule (.*register.php) register.php [L,NC] ## Deny access to extension xml files (u

目前,我的网站正在将所有扩展名为.php的页面重定向到Index.php页面
但是我不想在register.php页面上看到这个,请帮助我。下面是我正在做的

DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule (.*register.php) register.php [L,NC]

## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.\(.\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).script.(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^.*$ https://%1/$1 [R=301,L]
DirectoryIndex.php
选项+FollowSymLinks
重新启动发动机
重写基/
重写规则(.*register.php)register.php[L,NC]
##拒绝访问扩展xml文件(取消注释以激活)
#
#命令允许,拒绝
#全盘否定
#满足所有
#
##拒绝访问扩展xml文件的结束
#阻止任何试图通过URL设置mosConfig值的脚本
重写cond%{QUERY\u STRING}mosConfig\[a-zA-Z\]{1,21}(\\%3D)[或]
#阻止任何试图通过URL发送base64_编码垃圾的脚本
重写cond%{QUERY\u STRING}base64\u encode.\(.\)[或]
#阻止在URL中包含标记的任何脚本
重写条件%{QUERY\u STRING}(\\\\%3E)[NC,或]
#阻止任何试图通过URL设置PHP全局变量的脚本
重写条件%{QUERY\u STRING}全局(|\[|\%[0-9A-Z]{0,2})[或]
#阻止任何试图通过URL修改_请求变量的脚本
重写条件%{QUERY\u STRING}\u请求(|\[|\%[0-9A-Z]{0,2})
#将所有被阻止的请求发送到主页,出现403禁止错误!
重写规则^(.*)$index.php[F,L]
#
##########结束-重写规则以阻止一些常见的漏洞攻击
重写cond%{REQUEST_FILENAME}!-f
重写cond%{REQUEST_FILENAME}!-d
重写cond%{REQUEST_URI}!^/index.php
重写cond%{REQUEST|u URI}(/|\.php|\.html|\.htm|\.feed |\.pdf|\.raw |/[^.]*)$[NC]
重写规则(.*)index.php
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION},L]
重写cond%{HTTP_HOST}^www\(.*)
重写规则^.*$https://%1/$1[R=301,L]
也许这样可以:

尝试修改此规则:
RewriteRule(.*register.php)register.php[L,NC]
为:

RewriteCond %{REQUEST_URI} register\.php [NC]
RewriteRule .* - [L]

你能举一个你想从规则中排除的请求的例子吗?几秒钟前我修改了我的答案,所以要排除的目录可以是任何级别的。也许你还没有尝试过当前版本。www.abc.com/fisrt.html www.abc.com/fisrt.htm www.abc.com/fisrt.php www.abc.com/second.php www.abc.com/register.php将被重定向到www.abc.com/index.php,但我不希望www.abc.com/register.php也被重定向到www.abc.com/index.php。当我运行页面www.abc.com/register.php时,我在URL栏中找到的地址是www.abc.com/register.php,但内容是index.php页面。我真的很感谢你的努力。但是@faa它不起作用:(请确保在进行任何测试之前清除浏览器的缓存。我不明白为什么它不起作用,但再次修改了我的答案,以包含另一个NOT条件,以确保在任何情况下,该规则都不会应用于包含字符串
register.php
的请求。是的,我清除了浏览器的缓存,但运气不佳。这是我的网站。我的内容php页面的s。