Forum Sondria46®   →   Sondria46_Blog   →   Blog_Articles   →   Password protect a specific URL

Password protect a specific URL

Started by admin Nov 06th, 2024 at 10:18
admin
Admin
Posts: 95
Nov 06th, 2024 at 10:18

To password-protect a specific URL, there are several methods depending on the type of server or framework you're using. Here are some common ways to password-protect a URL.

1. Using .htaccess on Apache Servers

If you're using an Apache server, you can set up basic HTTP authentication using a .htaccess file.

  1. Create a .htpasswd file with username and password:

    • You can create this file by running the following command:
    • htpasswd -c /path/to/.htpasswd username
    • Replace /path/to/.htpasswd with the path where you want the file saved, and username with the desired username.
    • This command will prompt you for a password and generate the file.
  2. Edit your .htaccess file in the directory containing the URL you want to protect:AuthType Basic
    AuthName "Restricted Access"
    AuthUserFile /path/to/.htpasswd
    Require valid-user
    Replace /path/to/.htpasswd with the actual path to the .htpasswd file.

  3. Test the URL: Visit the URL, and you should be prompted to enter the username and password.

 

« Last Edit: Nov 06th, 2024 at 10:19 by admin »


Home   •   FAQ   •   Support   •   Terms of Service   •   Privacy   •   News   •   Forum
Copyright © 2024 Sondria46®. All Rights Reserved.
Powered by EvolutionScript Version 6.6