How to Publish .php files as Plain Text

Two months ago I was looking for a way to let apache serve python scripts as plain text. Today I had the same problem with php files. Here is my solution.

What you need is a .htaccess file in the same directory as the files you want to serve, with the following directive in it:

AddType text/plain .php

Be carefull: within the directory, anybody will be able to look the source code of all files with .php extension.

2 thoughts on “How to Publish .php files as Plain Text

  1. You may also need to add the following directive before the AddType one:

    RemoveHandler .php
    

    FYI, I had to add this on my case because I run the CGI version of PHP.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.