如何在Apache中将不带扩展名的文件视为php [英] How to have files without extensions treated as php in Apache
本文介绍了如何在Apache中将不带扩展名的文件视为php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Apache中浏览目录时,我希望单击时没有扩展名的文件被服务器视为php(那些包含php代码的文件).
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).
推荐答案
您可以使用apach模式重写的H标志来强制所有没有扩展名的文件都由php处理程序解析:
You can use the H flag of apach mode rewrite to force all files without an extension to be parsed by The php handler :
在htaccess中尝试以下操作:
try the following in htaccess :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\. - [H=application/x-httpd-php]
在某些服务器上,您必须通过httpd-php5更改httpd-php:
on some servers, you have to change httpd-php by httpd-php5 :
RewriteRule !\. - [H=application/x-httpd-php5]
这篇关于如何在Apache中将不带扩展名的文件视为php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文