What's new

Welcome to KodeBlend Forums

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask question

Ask questions and get answers from our community

Answer

Answer questions and become an expert on your topic

Contact us

Contact the site administrator directly.

Telegram

Join Telegram Channel to stay updated.
ifastnet

Protecting admin.php, the /install directory, and test & development installations using .htaccess

KodeBlend

Administrator
Staff member
Administrator
Moderating
Top Poster Of Month
Joined
Dec 17, 2023
Messages
4,719
Reaction score
1,130
Points
226
Location
Universe
Website
kodeblend.us
If you want to provide an extra layer of protection to admin.php, the /install directory, and test & development installations, you can do so with .htaccess authentication.


Protecting admin.php
To protect admin.php, edit the .htaccess file which is in your forum root directory (e.g. /community) and add the following to it:
Code:
Code:
Please, Log in or Register to view codes content!
The "path/to/passwd/file" will look something like "/home/my-domain/.htpasswds/public_html/community/passwd".

Then create a corresponding passwdfile. This is how to do it using cPanel.
  1. Log in to cPanel
  2. Click on Password Protect Directories
  3. Select Web Root
  4. Click on the forum root folder
  5. Check Password protect this directory
  6. Name it as "ACP"
  7. Click Save
  8. Create User
  9. Enter Username
  10. Enter Password
  11. Click on Add/modify authorised user
A passwdfile will be created in /.htpasswds/public_html/<name_of_your_forum_root_folder> .


Protecting the /install directory
To protect the /install directory, create a new .htaccess file in /install and add the following to it:
Code:
Code:
Please, Log in or Register to view codes content!

In this case it is using the same passwdfile as for the ACP so just repeat the steps above to create a different one.


Protecting test and development installations
The
Please, Log in or Register to view URLs content!
state that any test and development installations "must be limited to You and Your website staff".
Again, just place the following at the top of the existing .htaccess file in the directory where XF is installed.
Code:
Code:
Please, Log in or Register to view codes content!

Set the user and password as explained above.
With it set at the root, it isn't necessary to set it for admin.php and the /install directory.


Using IP address based protection instead of passwd
You can also use IP address protection instead of a passwdfile. In which case you would just have this in the .htaccess file for admin.php:
Code:
Code:
Please, Log in or Register to view codes content!
And this for the /install directory:
Code:
Code:
Please, Log in or Register to view codes content!

Replace 127.0.0.1 with your actual IP address. You can find out your IP address
Please, Log in or Register to view URLs content!
.
Additional allowed IP addresses can be added on a new line.

If you have a static IP address then this approach is fine. If it's dynamic however, you will need to constantly update the file every time it changes.
 
shape1
shape2
shape3
shape4
shape5
shape6
Back
Top
Start a Conversation
Hi! Click one of our member below to chat on Whatsapp
The team typically replies in a few minutes