Magento SKIN and VAR Folder Permission

Magento SKIN and VAR Folder Permission

October 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento SKIN and VAR Folder Permission

Securing Magento SKIN Folder from Direct URL Access

As a senior developer specializing in e-commerce platforms like Magento, I often encounter security concerns around sensitive folders such as skin and var. In this post, we’ll dive into the issue of preventing direct URL access to the skin folder while still allowing your Magento site to function correctly.

Understanding the Problem

Your current setup has the skin folder set to 755 permissions. While this allows your site’s CSS files to load properly, it also grants public read access to all contained files via a browser URL. This poses a security risk as it exposes your server files and potentially sensitive data.

Meanwhile, the var folder is inaccessible via URL even with 755 permissions because of Apache configuration that specifically restricts access to this directory using .htaccess. We aim to replicate this behavior for the skin folder without disrupting your site’s styling.

Solving the 644 vs. 755 Dilemma

You’ve noticed that setting the skin folder permissions to 644 causes CSS files not to load, resulting in a broken site appearance. This is because Magento needs read and execute permissions for its cache and compilation mechanisms.

However, simply increasing permissions to 755 provides too much access as discussed earlier. The key lies in finding a middle ground that balances security with functionality.

The .htaccess Solution

To achieve this, we’ll create an .htaccess file inside the skin folder and configure it to deny all requests while still allowing Magento’s internal processes:

  1. Inside your skin folder (both admin and frontend), create a new file named /.htaccess.

  2. Add the following content to the new file:

Order allow,deny
Deny from all
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /skin
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|robots\.txt)
RewriteRule . index.php [L]
</IfModule>
  1. Save and close the file.

Explaining the Configuration

The Order allow,deny and Deny from all lines restrict access to any files or directories within the skin folder for all users except for the server itself.

The Rewrite rules then handle Magento’s internal URL rewriting needs while continuing to serve static assets like images directly (which is vital for performance).

Ensuring Proper Functionality

After applying this solution, your CSS files should still load correctly as the .htaccess configuration only blocks direct file access and doesn’t interfere with Magento’s core functionality.

However, you must ensure that the .htaccess file has the correct permissions:

  • The file itself: 644 (readable by all, writable by owner)
  • The folder containing it: 755

Conclusion

Securing sensitive folders in a Magento installation requires a delicate balance of permissions and configuration. By leveraging Apache’s .htaccess capabilities and properly managing directory permissions, you can effectively prevent unauthorized access to the skin folder while maintaining your site’s appearance and performance.

Remember, regular security audits are crucial for identifying potential vulnerabilities like these. Always keep your Magento core files and extensions up-to-date to benefit from the latest security patches.

For more in-depth guides on Magento security best practices, feel free to explore our resources at LaravelCompany.

Cache Security API Themes

Our network