Reputation: 27
Rule bellow should block any direct access to all *.php
files:
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?
example:
all *.php
files (ignored if accessed directly)
cronjob.php, specialpage.php
(should be ignored by the rule above and direct access should be allowed.)
can you please show example of (1) or (2 or more) files excluded.
PS: if such rule to exclude those files exists, what flag needs to be applied? [L]
or [R,L]
or ????
Upvotes: 1
Views: 95
Reputation: 784998
You can use negation in RewriteRule
:
RewriteCond %{THE_REQUEST} ^.+?\ [^?]+\.php[?\ ] [NC]
RewriteRule !(^|/)(cronjob|specialpage)\.php$ - [F,NC]
Upvotes: 2