Disabling PHP in Subdirectories with .htaccess
To prevent the execution of PHP in specific directories, including their subdirectories, while allowing Server-side includes (SSI), follow these steps:
In your project's root directory, create or edit the .htaccess file.
Add the following code to the .htaccess file:
php_flag engine off
This code disables the PHP engine in the current directory and all its subdirectories.
After adding the code, save and upload the .htaccess file.
To enable SSI, add the following line to the .htaccess file:
AddType text/x-server-parsed-html .shtml
This line allows SSI execution for files with the .shtml extension.
Restart your web server to apply the changes.
Now, any PHP files in the /USERS directory and its subdirectories will no longer be executed, while SSI files will still function as intended.
The above is the detailed content of How to Disable PHP in Subdirectories while Enabling SSI with .htaccess?. For more information, please follow other related articles on the PHP Chinese website!