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

  • Home
  • SEARCH
  • 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 8881199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:17:51+00:00 2026-06-14T20:17:51+00:00

Related to my previous question: .htaccess check for cookie first, then valid-user Hi guys,

  • 0

Related to my previous question: .htaccess check for cookie first, then valid-user

Hi guys, I really would appreciate some help from the experts here. My httpd.conf should require a user login using mod_auth_mysql OR a cookie – but now it’s only checking for a user login. The code from the previous question is now located in my httpd.conf.

What’s Working:

Currently, all /var/www/downloads and subdirectories for users (/var/www/downloads/~username~) require a username and password using mod_auth_mysql. This works.

What’s not working:

The problem is: I have settings which SHOULD require either a login using mod_auth_mysql (works), or a cookie (doesn’t work). If the cookie is present, then it should automatically display the contents of the directory when a user goes to /var/www/downloads/. But it doesn’t, it asks for a username/password still.

I’m using SetEnvIf, but it might be being used incorrectly with “satisfy all”. I might have conflicts between httpd.conf and /sites-enabled/000-default. I’m not experienced with most of the stuff here, so any help would be massively appreciated!

HTTPD.conf:

RewriteEngine on
RewriteLogLevel 9
RewriteLog /var/www/logs/rewrite.log

#Block IPs
<Directory /var/www>
    RewriteEngine On

    #only use my server for apache
    RewriteCond %{HTTP_HOST} !^2.2.2.2$ [NC]
    RewriteRule ^(.*)$ http://www.google.co.uk/$1 [L,R=301]

    RewriteCond %{REMOTE_ADDR} 0.0.0.0 [NC,OR]
    RewriteCond %{REMOTE_ADDR} 1.1.1.1 [NC]
    RewriteRule ^(.*)$ http://www.google.com [R]
</Directory>

# DOWNLOADS TOP DIRECTORY
<Directory /var/www/downloads>
    #Options Indexes
    #AllowOverride All
    #Order deny,allow
    #Deny from all
    #Allow from All

    AuthName "Please don't hack the server, thanks"
    AuthBasicAuthoritative Off
    AuthUserFile /dev/null
    AuthMySQL On
    AuthType Basic
    Auth_MYSQL on
    Auth_MySQL_Host localhost
    Auth_MySQL_User user
    Auth_MySQL_Password password
    AuthMySQL_DB db
    AuthMySQL_Password_Table users
    Auth_MySQL_Username_Field username
    Auth_MySQL_Password_Field password
    Auth_MySQL_Empty_Passwords Off
    Auth_MySQL_Encryption_Types Plaintext
    Auth_MySQL_Authoritative On
    require user luke

</Directory>

# EXAMPLE USERS DIRECTORY
# MIKE
<Directory /var/www/downloads/mike>
    SetEnvIf Cookie (.*)cookiename(.*) norequire_auth=yes
    Order Deny,Allow
    deny from all
    Satisfy Any

    #MYSQL AUTH
    AuthName "Please login"
    AuthBasicAuthoritative Off
    AuthUserFile /dev/null
    AuthMySQL On
    AuthType Basic
    Auth_MYSQL on
    Auth_MySQL_Host localhost
    Auth_MySQL_User user
    Auth_MySQL_Password password
    AuthMySQL_DB db
    AuthMySQL_Password_Table users
    Auth_MySQL_Username_Field username
    Auth_MySQL_Password_Field password
    Auth_MySQL_Empty_Passwords Off
    Auth_MySQL_Encryption_Types Plaintext
    Auth_MySQL_Authoritative On
    require user mike

    #COOKIE AUTH
    Allow from env=norequire_auth
</Directory>

​In case it may help, sites-enabled/000-default: may be causing conflicts? http://jsfiddle.net/Xcece/

I’m not using .htaccess files. I have changed a load of directives around and have gotten quite lost.

I can’t for the life of me figure out why it’s not working – I don’t quite understand the conflicts that may exist, so a point in the right direction with explanation so I can avoid this in the future would be great. Thank you.

  • 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-06-14T20:17:51+00:00Added an answer on June 14, 2026 at 8:17 pm

    Finally! After a week searching…

    The problem was with setting the cookie. Having the files in different directories meant that the cookie wasn’t being read correctly by the httpd.conf – which is in fact correct.

    I had to set the fourth parameter for the cookie to ‘/downloads/mike’ thereby allowing it to be read by the httpd.conf file correctly.

    session_start();
    setcookie("cookiename","cookiename",time() + 3600, '/downloads/mike');
    

    Just remember when destroying the cookie using time()-x to destroy it using the fourth parameter /downloads/mike.

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

Sidebar

Related Questions

Related to my previous question , is there some realistic chance to extract surveillance
Ok guys, this question is related to my previous one. If I have set
This is kind of related to my previous question, but not really. I have
Related to my previous question , I have a string on the following format:
This is related to my previous question I'm solving UVA's Edit Step Ladders and
This question is related to a previous question of mine That's my current code
This is related to my previous question More than 1 Left joins in MSAccess
Very much related to my previous question , but I found this to be
This is related to my previous question here . I want 4 divs (absolute
This question is related to my previous question How to generate Cartesian Coordinate (x,y)

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.