Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show php-files as plain text in Apache

Tags:

php

apache

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.

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

THANKS!

like image 224
mdthh Avatar asked Nov 21 '10 07:11

mdthh


1 Answers

My Godaddy setup wont allow me to edit the httpd.conf files, and the php_flag command doesn't work due to how they've implemented php for me.

I was able to use this in my .htaccess file:

SetHandler default-handler
AddType text/plain php

I put this in the directory above where my FTP user is allowed to access, which forces all PHP files in that directory, as well as all sub-directories to show php as plain text.

This will work for other file types as well. All you need to do is add another line with whatever extension of file you want to be forced to display in plain text. AddType text/plain cgi for example

like image 131
Taylor Avatar answered Oct 22 '22 19:10

Taylor