Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6867311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:17:38+00:00 2026-05-27T03:17:38+00:00

I need to password protect on specific URL, for instance anyone can access index.php

  • 0

I need to password protect on specific URL, for instance anyone can access index.php but as soon as they add parameters or “GET” variables I must require valid-user.

index.php -> sweet

index.php?prev=1 -> require valid user

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:17:38+00:00Added an answer on May 27, 2026 at 3:17 am

    Interesting question.

    Here’s a solution:

    <Location /fakeindex.php>
      Order Deny,Allow
      Deny from All
      Allow from env=REDIRECT_STATUS
      AuthType Basic
      AuthUserFile /pathto/htpasswd/file/passwords.secret
      AuthName This is an example auth
      Require valid-user
    </Location>
    <Directory /path/to/doc/root>
        Order allow,deny
        allow from all
        RewriteEngine On
        RewriteCond %{QUERY_STRING} .
        RewriteCond %{REQUEST_URI} index.php
        RewriteRule .* fakeindex.php [L,QSA]
    </Directory>
    

    This part:

      Order Deny,Allow
      Deny from All
      Allow from env=REDIRECT_STATUS
    

    is there to prevent a direct access to /fakeindex.php (but in fact who would like to enforce a direct access to a protected zone). It’s optionnal.

    The key point is that theses condition Rules detect a non empty Query string, and a request to index.php:

        RewriteCond %{QUERY_STRING} .
        RewriteCond %{REQUEST_URI} index.php
    

    And that if they match the Rule:

    RewriteRule .* fakeindex.php [L,QSA]
    

    Redirect internally the request to /fakeindex.php, keeping the query string with QSA. After that the Location is applied, and authentification is on the Location.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to password protect my application but need advice on where to store
Do we need to set permission to access the server with username password authentication
I need to password protect a couple of entries on a site. It is
I need to zip and password-protect a file. Is there a good (free) library
What is the best way to password protect folder using php without a database
How can we able to protect a site using USERNAME and PASSWORD after we
I am new to ruby. I need to receive password as an input through
I need to pass an ID and a password to a batch file at
I need to store the user's password in my iphone app. When posting an
I need to hash (MD5) all the password in our Sql Server 2000 database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.