如何在 Apache 中将 php 文件显示为纯文本

问题描述:

对于我本地 Apache 服务器上的某个文件夹(与 Ubuntu 一起运行),我希望所有 *php 文件都显示为纯文本文件.我需要这个,因为我只想查看这些文件的源代码而不是运行它们.

for a certain folder on my local Apache-Server (running with Ubuntu) I'd like that all *php-files will be displayed as if they were plain text-files. I need this since I only want to see the source code of these files and NOT run them.

在搜索时,我发现大多数人都有相反的问题 :-) 并且无法真正为我找到解决方案.

While searching, I found that most people have the opposite problem :-) and couldn't really find a solution for me.

我需要在文件夹的 .htacces-file 中包含什么?

What would I need to include in the .htacces-file of my folder?

谢谢!

答案:

在 .htaccess 文件类型中

in .htaccess-file type

php_flag engine off 
#This will prevent apache from executing *.php-files

AddType text/plain php
#this wil display php-files in browser (if not, browser will want to download file!)

感谢布拉德!