Automatically set permission to various file types using .htaccess

Nov 29, 2013, by admin

Set file permissions with .htaccess, this is a great method for ensuring the CHMOD settings for various file types.

Apply the following rules in the root .htaccess file to affect all specified file types, or place in a specific directory to affect only those files (add/update file types according to your needs)
# ensure CHMOD settings for specified file types
# never set CHMOD 777 unless you know what you are doing?
# files requiring write access should use CHMOD 766 rather than 777
# keep specific file types private by setting their CHMOD to 400

chmod .htpasswd files 640
chmod .htaccess files 644
chmod php files 600

Require SSL (Secure Sockets Layer)

Here is an easy way you can go using .htaccess file
# require SSL without mod_ssl
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Hope you all like the post to get more updates like the page Bugtreat Technologies and like the page Cs Cart Templates for our latest templates updates