Home » Php » Is it possible to have password protection on everything but query strings only (.htaccess)

Is it possible to have password protection on everything but query strings only (.htaccess)

Posted by: admin July 14, 2018 Leave a comment

Questions:

How would I go about making a .htaccess file for my Apache Server 2.4, so that you would be able to access https://www.development.stech.software/index.php?q=WILDCARD, but you couldn’t access https://www.development.stech.software or https://www.development.stech.software/index.php because they were password protected.

You can check out the website, it is a proxy server. I know the basics of a .htaccess file, but I am not sure how to make it so that it only allows query strings and password protects everything else.

I’ve been reading up on some other questions and found something like this:

SetEnvIf Request_URI ^/index.php?q=* noauth=1

AuthName "Please login."
AuthType Basic
AuthUserFile htdocs/.htpasswd

Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=noauth 

and

SetEnvIf Request_URI ^/index.php?q=* auth=1

AuthName "Please login"
AuthType Basic
AuthUserFile "htdocs/.htpasswd"

Order Allow,Deny
Satisfy any
Allow from all
Require valid-user
Deny from env=auth 

It didn’t work, nor do I understand it, but I thought I should take a shot at it. Please let me know what I’m doing wrong or how should I go about doing what I need to do.

Answers: