How to have files without extensions treated as php in Apache

浪尽此生 提交于 2021-01-27 05:49:26

问题


While browsing directories in Apache I would like to have the files that have no extension to be treated by the server as php when clicking on them (those files containing php code).


回答1:


You can use the H flag of apach mode rewrite to force all files without an extension to be parsed by The php handler :

try the following in htaccess :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\. - [H=application/x-httpd-php]

on some servers, you have to change httpd-php by httpd-php5 :

RewriteRule !\. - [H=application/x-httpd-php5]



回答2:


According to Apache, you should not be using .htaccess: https://httpd.apache.org/docs/current/howto/htaccess.html#when

For the answer to your question, read my post here: https://stackoverflow.com/a/59868481/10664600

sudo vim /etc/httpd/conf/httpd.conf


来源:https://stackoverflow.com/questions/33933480/how-to-have-files-without-extensions-treated-as-php-in-apache

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!