Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Authorization |
|
Author |
|
pascalprogrammer
Joined: 17 Feb 2025 Posts: 1
|
Posted: Mon 17 Feb '25 11:37 Post subject: Authorization |
|
|
Hey,
This is my .htaccess file:
Code: | <If "-f %{DOCUMENT_ROOT}/.htpasswd">
AuthType Basic
AuthName "Restricted Access"
AuthUserFile ".htpasswd"
Require valid-user
</If>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule> |
My problem: if I enter my username and password, I have to enter them again and again. Infinite loop.
My solution is perfect without <If "-f %{DOCUMENT_ROOT}/.htpasswd"> and </If> lines.
How can this be solved?
I have an idea, but I don't know how to solve it.
Code: | <If "-f %{DOCUMENT_ROOT}/.htpasswd">
# check, if not authorized ->
AuthType Basic
AuthName "Restricted Access"
AuthUserFile ".htpasswd"
Require valid-user
# <- check, if not authorized
</If> |
What I would like: if there is a .htpasswd file, you should be able to log in, if there isn't, you don't have to.
Thanks. |
|
Back to top |
|
Stray78

Joined: 15 Apr 2024 Posts: 35 Location: USA
|
Posted: Tue 18 Feb '25 4:43 Post subject: |
|
|
Aren't you missing the most important part?
AuthUserFile "%{DOCUMENT_ROOT}/.htpasswd"
Try This...
Code: | <If "-f %{DOCUMENT_ROOT}/.htpasswd">
# check, if not authorized ->
AuthType Basic
AuthName "Restricted Access"
AuthUserFile "%{DOCUMENT_ROOT}/.htpasswd"
Require valid-user
# <- check, if not authorized
</If>[/b] |
|
|
Back to top |
|
|
|
|
|
|