Using Apache it's easy to enable PHP for all files of any extension:
AddHandler application/x-httpd-php .css .js .txt .xml
How do I enable PHP for only a specific file but not all other files with that same extension?
I have tried AddHandler application/x-httpd-php test.xml
and it did not work and the search engines aren't coughing up anything remotely relevant.
AddHandler can be used inside a <Files> container.
AddHandler Directive
- Description: Maps the filename extensions to the specified handler
- Context : server config, virtual host, directory , .htaccess
... where directory
stands for:
directory
A directive marked as being valid in this context may be used inside <Directory>, <Location>, <Files> , <If>, and <Proxy> containers in the server configuration files, subject to the restrictions outlined in Configuration Sections.
And <Files> can be used from .htaccess
just fine:
<Files> Directive
- Description: Contains directives that apply to matched filenames
- Context: server config, virtual host, directory, .htaccess
Simply:
<Files hello.html>
AddType application/x-httpd-php .html
</Files>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.