Reputation: 3
How I can restrict access to files with htaccess from all IPs except one? I want to restrict access from all IPs to php files expect one IP I mean I want to allow 192.168.1.200 to see php files and Others IPs restrict to see php files And also Other IPs should access to see other file types like images
Upvotes: 0
Views: 152
Reputation:
Try this one:
<FilesMatch "\.(php)$">
Order allow,deny
Deny from all
Allow from 192.168.1.200
</Files>
it matches all php files and allows only for the specified ip. you should consider adding a 403-error handler
Upvotes: 0
Reputation: 786061
Put this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
# If IP is not 192.168.1.200
RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.200$
# block access to all .php files
RewriteRule \.php$ - [F,NC]
Upvotes: 1