i have following htaccess code in order to block all .php files.
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^?\ ]*\.php[/?\ ]
RewriteRule .*\.php$ 404.php [L]
but how i can block only files not in root.
example
mywebsite/index.php - don't want to block
mywebsite/go/go.php - want to block
mywebsite/en/en.php - want to block
Not sure how that isn't looping, but you want to change your matching regular expression to include at least 1 depth in your path:
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^?\ ]*\.php[/?\ ]
RewriteRule ^[^/]+/.*\.php$ 404.php [L]
Also, see Marc B's comment.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.