Force a File to Display Instead of Executing
November 5th, 2007
If you’re like me, you run a site written in PHP. Sometimes I offer PHP scripts to my readers and want them to be able to download them, but if I post a link, the script is executed instead. You can prevent this action with a small .htaccess tweak.
If you install this tweak in the .htaccess file at the root of your domain, it will be applied site-wide, however, you may find it better to keep it within certain subdirectories that are intended to house publicly available scripts.
The following example would force PHP and Python or Perl CGI scripts to display as text in the browser rather than executing as is there default action.
RemoveHandler cgi-script .pl .py .cgi RemoveHandler application/x-httpd-php .php

































