How can .htaccess be used to protect directories containing PHP scripts while still allowing external access?

To protect directories containing PHP scripts while still allowing external access, you can use .htaccess to restrict access to the directory by IP address. This way, only specific IP addresses will be able to access the directory, while others will be denied access. ```apache # Restrict access to directory by IP address <FilesMatch "\.php$"> Order deny,allow Deny from all Allow from 192.168.1.1 </FilesMatch> ```