• Skip to main content
  • Skip to primary sidebar

xfpoint

XenForo Resource Site with Tips, Tricks and Hacks

  • Home
  • About
  • Glossary
  • Guides
  • Tutorials
  • Add-ons
  • Contact
You are here: Home / Tutorials / How to Protect XenForo Admin Area with .htaccess

How to Protect XenForo Admin Area with .htaccess

November 12, 2017 by Shabbir Bhimani

XenForo admin area isn’t inside its own directory but is accessible via the admin.php file in the forum’s main directory. So one can’t add htaccess based password protection to a directory but still one can provide an extra layer of security to admin.php with .htaccess.

Protect a Dummy Directory

Log in to CPanel and inside the file manager, browse through the forum directory and create a dummy directory inside the forum directory. It is done to make sure we have the username and password available to protect the admin.php file. If you already have a username and password, you can skip this step.

Now return to the CPanel home and look for Directory Privacy option under the Files option.

Browse to the dummy directory created and protect this directory with a password.

Password Protect the admin area

Go back to the File manager and you will find a .htaccess file created inside the dummy folder. The content of the file will be as follows:

AuthType Basic
AuthName "XenForo Admin"
AuthUserFile "/home/********/.htpasswds/public_html/dummy/passwd"
require valid-user
view raw .htaccess hosted with ❤ by GitHub

Now open the forum root’s .htaccess file and copy the content from the above .htaccess and wrap it around only for the admin.php file as follows:

<Files admin.php>
AuthType Basic
AuthName "XenForo Admin"
AuthUserFile "/home/********/.htpasswds/public_html/dummy/passwd"
require valid-user
</Files>
view raw .htaccess hosted with ❤ by GitHub

Save the file and you will have a prompt from Apache when accessing admin area.

Manage access to the XenForo admin by providing them access to the dummy folder. Every user added/modified for the dummy folder will have access to the XenForo admin area.

Tighten the security further for admin.php by allowing access only from the selected IP addresses as follows:

<Files admin.php>
Order Deny,Allow
Deny from all
Allow from XX.XX.XX.XX
Allow from YY.YY.YY.YY
</Files>
view raw .htaccess hosted with ❤ by GitHub

Place the above code in the forum root’s .htaccess file as a separate block.

Note: If you have a dynamic IP, having an IP based restriction can mean you have to add your IP’s each time you may want to access the admin area or else you may see a server error.

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)

Filed Under: Tutorials Tagged With: Apache, Cpanel, htaccess, htpasswd, IP Address, Password, Security

About Shabbir Bhimani

xfpoint.com is an independent XenForo resource site with tips, tricks, hacks, and resources for new XenForo webmasters to improve their community. Read More…

Primary Sidebar

About Shabbir Bhimani

xfpoint.com is an independent XenForo resource site with tips, tricks, hacks, and resources for new XenForo webmasters to improve their community. Read More…

© xfpoint 2025. xfpoint.com is an independent XenForo resource site for new xenForo webmasters.

Copyrighted code samples of XenForo will be visible only if you have a valid xenForo license.