简体   繁体   English

允许直接访问特定的php文件

[英]Allow direct access for specific php file

Rule bellow should block any direct access to all *.php files: 波纹管应阻止对所有*.php文件的任何直接访问:

RewriteCond %{THE_REQUEST} ^.+?\ [^?]+\.php[?\ ]
RewriteRule \.php$ - [F]

Is there a way to exclude 1 or 2 php files to be ignored by this global rule? 有没有一种方法可以排除1或2个此全局规则忽略的php文件?

example: 例:

all *.php files (ignored if accessed directly) 所有*.php文件(如果直接访问,则忽略)

cronjob.php, specialpage.php (should be ignored by the rule above and direct access should be allowed.) cronjob.php, specialpage.php (应被上述规则忽略,并应允许直接访问。)

can you please show example of (1) or (2 or more) files excluded. 您能否显示排除的(1)或(2个或更多)文件的示例。

PS: if such rule to exclude those files exists, what flag needs to be applied? PS:如果存在排除这些文件的规则,则需要应用什么标志? [L] or [R,L] or ???? [L][R,L]或????

You can use negation in RewriteRule : 您可以在RewriteRule使用否定:

RewriteCond %{THE_REQUEST} ^.+?\ [^?]+\.php[?\ ] [NC]
RewriteRule !(^|/)(cronjob|specialpage)\.php$ - [F,NC]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM