How to Restrict Access to Directories by IP Address Print

  • 0

Updated guide: This article has been refreshed for current hosting environments. Control-panel labels and available features can vary slightly by account, server configuration, or software version, but the workflow below follows the current approach used on modern hosting platforms. This guide is written to help you complete How to Restrict Access to Directories by IP Address safely and understand what to check if the expected result does not appear.

Before you begin

  • Create a current backup of the database and website files before major updates or configuration changes.
  • Confirm that your PHP version and hosting resources are suitable for the current WordPress release and installed plugins.
  • Update plugins and themes from trusted sources only.
  • If the site is business-critical, test major updates on a staging copy before applying them to production.

Keeping WordPress secure

WordPress core, plugins and themes should be kept current because updates can contain security fixes as well as compatibility and performance improvements. WordPress supports automatic updates for individual plugins and themes, but automatic updates should be used with a reliable backup and a recovery plan. Current WordPress documentation recommends regular backups before relying on automatic updates.

When an update breaks the site

  1. Identify what changed immediately before the problem appeared.
  2. Check the PHP/server error log for the actual fatal error or warning.
  3. Temporarily disable the suspected plugin or theme if you can safely do so.
  4. Restore the previous version or a known-good backup if the issue cannot be resolved quickly.
  5. Update the affected component only after confirming compatibility.

Troubleshooting and recovery

  • White screen or fatal error: If the problem started immediately after a plugin or theme change, disable the suspected component and check the PHP error log. Restore a known-good backup if necessary.
  • Update failed: Confirm that the site has a current backup, sufficient disk space, a supported PHP version and working filesystem permissions before trying again.
  • Site is slow after an update: Clear application/cache layers and test the site with non-essential plugins temporarily disabled. Avoid installing multiple caching plugins that perform the same job.
  • Login or admin page unavailable: Check the site URL, SSL configuration, security plugins and server error logs before making database changes.

When to contact support

Contact support when the required feature is unavailable, a server-level service is failing, an account is locked, a restore requires privileges you do not have, or you have verified the settings but the service still does not work. When contacting support, include the domain name, the exact error message, what you changed, when the issue started, and screenshots or log output where appropriate. Do not send passwords or other authentication secrets.

Original illustrated procedure

To secure your admin area from hackers, you should only allow access to your admin directory from selected IP addresses. You can create a dot htaccess file in the directory where you want to restrict access to specific IP addresses.

For example, if you have a WordPress blog installed on your main directory and you log in via example.com/wp-admin, you should create an htaccess file in /wp-admin/.htaccess and put the following code into it. Please, don't forget to replace the allowed IP address with your IP address.

order deny, allow
deny from all
allow from YOUR-IP-ADDRESS-HERE


Replace the Your-IP-Address-Here text with your IP address.


You can test this by accessing the wp-admin directory from another IP address, not mentioned in your htaccess file.


Was this answer helpful?

« Back