Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have files without extensions treated as php in Apache

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).

like image 861
jck Avatar asked Nov 26 '15 08:11

jck


Video Answer


1 Answers

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]
like image 188
Amit Verma Avatar answered Sep 30 '22 04:09

Amit Verma