Forum Moderators: open
Is there an .htaccess hack to turn off execution?Pretty sure you can tell it to interpret php files as plain text, so all they get is the text content of their own php script thrown back into their faces. (With a further vague idea that I once achieved this by accident.) AddType? AddOutputFilter? AddHandler?
<Directory /home/example/www/cache>
<FilesMatch "\.(?i:php|htaccess)$">
Require all denied
</FilesMatch>
</Directory> <Directory /home/example/www/cache>
RemoveHandler .php
</Directory> I don't understand the ?i, though.Doesn't it mean “what follows is case-insensitive”?
<FilesMatch "^\.ht">
Require all granted
</FilesMatch>
# scary, huh?
I made it once to amuse someone hereabouts, though I no longer remember the full backstory. The point was that you can enter example.com/directory/.htaccess in your browser ... and actually see the htaccess. A <LimitExcept> section should always be used in preference to a <Limit> section when restricting access, since a <LimitExcept> section provides protection against arbitrary methods.which is a good point. As an alternative to FilesMatch, you could set an environmental variable--in fact this is one of Apache's first examples for the use of a SetEnvIf directive--and then say "Require env image" or whatever you choose to call it.