WordPress admin appears unstyled after enabling “Restrict access to files and directories”

Symptoms

After enabling the Restrict access to files and directories security option in WordPress Manager, the WordPress admin area may appear unstyled or broken.

Typical symptoms include:

  • The WordPress admin displays without its normal styling.
  • Menus, buttons and page elements appear as plain text.
  • Browser Developer Tools show wp-admin/load-styles.php and/or wp-admin/load-scripts.php returning a 403 Forbidden response.

Cause

The Restrict access to files and directories security measure can block direct access to WordPress’s combined CSS and JavaScript loader files:

  • wp-admin/load-styles.php
  • wp-admin/load-scripts.php

WordPress normally uses these files to combine multiple admin CSS and JavaScript files into fewer requests. When access to them is blocked, the WordPress dashboard may load without its normal styling or functionality.

Solution

Add the following line to the website’s wp-config.php file:

define('CONCATENATE_SCRIPTS', false);

Place it above the following line:

/* That's all, stop editing! Happy publishing. */

For example:

define('CONCATENATE_SCRIPTS', false);

/* That's all, stop editing! Happy publishing. */

What this change does

This setting tells WordPress to load the individual CSS and JavaScript files directly instead of using load-styles.php and load-scripts.php.

It allows the Restrict access to files and directories security measure to remain enabled while restoring the normal appearance and functionality of the WordPress admin area.

After making the change

  1. Save the wp-config.php file.
  2. Clear any website, server or browser cache.
  3. Refresh the WordPress admin area.

The WordPress dashboard should now display normally.

Was this answer helpful? 1 Users Found This Useful (1 Votes)