Home > Backend Development > PHP Tutorial > How to Disable PHP in Subdirectories while Enabling SSI with .htaccess?

How to Disable PHP in Subdirectories while Enabling SSI with .htaccess?

Mary-Kate Olsen
Release: 2024-11-16 12:51:03
Original
585 people have browsed it

How to Disable PHP in Subdirectories while Enabling SSI with .htaccess?

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
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template