Admin
Moderating
Donor Member
Master Member
Elite Member
Active Member
- May 31, 2020
- 2,980
- 1,693
This guide follows the same hardening strategy: set proper file permissions first, then apply webserver rules to block unauthorized access, prevent PHP execution inside upload folders and protect sensitive configuration files.
If you run into 403 errors after applying these rules, create a support thread with your webserver type and configuration.
1. File & Folder Permissions
Never use global 777 permissions.- Regular folders: 755
- Static files (php, tpl, twig, css, js): 644
- Folders requiring write access (only these):/img/, /upload/, /var/cache/, /var/logs/, /var/uploads/Set these writable directories to 755. If your hosting needs group write permission, use 775.
- Core folders to keep read-only: /src/, /controllers/, /classes/, /modules/, /themes/
- Security cleanup: Delete /install folder completely after finishing installation.
2. Apache (.htaccess, site root)
- Disable directory listing
Options -Indexes
- Block direct access to sensitive core folders
<DirectoryMatch "^/(src|classes|controllers|config|translations)">
Require all denied
</DirectoryMatch>
- Block PHP execution inside image and upload directories
<Directory "/img">
<FilesMatch "\.(php|phtml|php5|twig)$">
Require all denied
</FilesMatch>
</Directory>
<Directory "/upload">
<FilesMatch "\.(php|phtml|php5|twig)$">
Require all denied
</FilesMatch>
</Directory>
- Protect configuration files
<Files "settings.inc.php">
Require all denied
</Files>
<Files "parameters.php">
Require all denied
</Files>
- Disable dangerous PHP functions (if host supports php_value)
php_value disable_functions eval,passthru,system,shell_exec,popen
3. Nginx server block rules
- Disable directory listing
autoindex off;
- Deny access to sensitive core directories
location ~ ^/(src|classes|controllers|config|translations)/ {
deny all;
}
- Prevent PHP execution in img and upload folders
location ~ ^/(img|upload)/.*\.(php|phtml|twig)$ {
return 403;
}
- Block access to sensitive config files
location ~ /(settings\.inc|parameters)\.php$ {
return 403;
}
- Restrict direct access to standalone PHP files
location ~* ^(?!/index\.php).*\.php$ {
return 403;
}
- Limit upload size
client_max_body_size 32M;
Additional PrestaShop security recommendations
- Rename or restrict backend access. Restrict admin access by IP in webserver config if you have static IP.
- Use strong admin passwords. Enable two-factor authentication inside PrestaShop back office.
- Remove unused modules and themes, delete leftover override files.
- Check logs regularly under /var/logs/.
- Always backup database and files before installing new modules or themes.
- Test webserver rules on staging first. Misconfigured rules may break frontend or backend access.
If you run into 403 errors after applying these rules, create a support thread with your webserver type and configuration.
Last edited: