Z.Kirik
Z.Kirik

Reputation: 121

Prevent direct access to .php files in .htaccess

I want to prevent direct access to php files to prevent bot attack

It is completely shut down with the following htaccess code. it didn't work for me

RewriteEngine on 
RewriteCond %{THE_REQUEST} \.php[\ /?].*HTTP/ 
(.*)\.php$ /index.html [L] 

Upvotes: 0

Views: 221

Answers (1)

TheBlueOne
TheBlueOne

Reputation: 496

If you want that just the server has access to your php files you can use this:

<Filesmatch "\.(php)$">
    Require local
</FilesMatch>

Upvotes: 1

Related Questions