问题
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