why is a .txt file being run as a php script?
Gordon Messmer
yinyang at eburg.com
Mon Oct 8 21:58:32 UTC 2012
On 10/08/2012 11:08 AM, Tom Horsley wrote:
> I have a sample .php script which I explicitly named with
> a .php.txt suffix so it would be treated as a plain text
> file, not a php script.
>
> Yet apache is clearly running the php script rather than just
> uploading the plain text copy of the script when I click
> on the link to the .php.txt file.
In the default configuration, .php.txt will use the php handler, because
.php is still of the file's extensions.
Instead of adding .txt (and thus adding a second extension), replace
.php with .txt.
http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addhandler
The extension argument is case-insensitive and can be specified with
or without a leading dot. Filenames may have multiple extensions and
the extension argument will be compared against each of them.
http://httpd.apache.org/docs/2.2/mod/mod_mime.html#multipleext
For example, if you wish to have the file foo.html.cgi processed as a
CGI script, but not the file bar.cgi.html, then instead of using
AddHandler cgi-script .cgi, use
<FilesMatch \.cgi$>
SetHandler cgi-script
</FilesMatch>
More information about the users
mailing list