.htaccess Tips & Tricks

From Metro Studios Knowledgebase

Jump to: navigation, search

[edit] Disable Script Execution

Disable execution of PHP and CGI scripts within a directory. This is useful for a PHP file uploads directory to prevent any malicious scripts from being uploaded and executed on the server.

Options -ExecCGI
php_flag engine Off
 
AddType text/plain .php .phps .phtml .php3
 
<FilesMatch "\.ph(p3?|tml|s)$">    
  SetHandler default-handler              
</FilesMatch>

[edit] Removed index.php from the url

To remove the threat of duplicate content issues between http://www.domain.com/directory/index.php and http://www.domain.com/directory/ we have to rewrite the index.php file back to it's immediate directory.

RewriteRule ^(.*)/index\.php$ $1 [R=301,L]
Personal tools
Namespaces
Variants
Actions
Wiki Navigation
Knowledgebase
Toolbox