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 4040178
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:43:08+00:00 2026-05-20T12:43:08+00:00

Good day everyone, I have a directory set up with some Apache Auth stuff.

  • 0

Good day everyone,

I have a directory set up with some Apache Auth stuff. Here is the directory:
http://gojalapeno.com/intranet/content/ado-jeune

Use ado-jeune:tezesyrab to login.

Here is the code for the .htaccess that powers it:

AuthName "Connexion au dossier:"
AuthType Basic
AuthUserFile "D:\Dropbox\htaccess\secret\.htpasswd"
Require valid-user

Now the login form for that directory is generated by the browser, but I wish to use my own HTML form for this. How can I do it? I’ve tried using cURL with PHP:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://gojalapeno.com/intranet/content/ado-jeune');
curl_setopt($ch, CURLOPT_USERPWD, 'ado-jeune:tezesyrab');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);

That authenticates fine, but the problem with that is that it doesn’t redirect to the page (despite the CURLOPT_FOLLOWLOCATION), it merely “includes” it in the current file. As such, all my relative links are broken.

So what I’m looking for is a way to use my own HTML form to authenticate to an Apache Basic Auth directory, and to redirect to that directory after.

Thanks!

  • 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-20T12:43:09+00:00Added an answer on May 20, 2026 at 12:43 pm

    Unfortunately, what you’re describing is going to be difficult to implement due to the way that AuthBasic works. From Apache’s documentation:

    Because of the way that Basic authentication is specified, your username and password must be verified every time you request a document from the server. This is even if you’re reloading the same page, and for every image on the page (if they come from a protected directory).

    Browsers handle sending the user’s credentials automatically for each subsequent request after the user enters them in.

    But in your case, the browser itself is not connecting to the protected directory, but rather cURL is. One solution would be to have cURL process all requests to that protected directory, in essence acting as a proxy.

    To accomplish this, you would have to write a PHP script that requests the user’s credentials and sends them along as it requests a page in the protected directory. So something like this:

    <?php
    
        // This is *very* basic - you would of course need to make sure the user 
        // isn't trying to access something in another location
        $dest = $_GET["dest"];
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'http://gojalapeno.com/intranet/content/' . $dest);
    
        // You would retrieve the user's credentials from an HTML form and save them in session vars
        curl_setopt($ch, CURLOPT_USERPWD, $_SESSION["username"] . ":" . $_SESSION["password"]);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    
        curl_exec($ch);
    
        curl_close($ch);
    
    ?>
    

    Hope this helps!

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

Sidebar

Related Questions

Good day everyone. I have an audio class, that plays a .wav file. But
Good day everyone, I am building a page in ASP.NET, and using Master Pages
Good day everyone. I am working on a Firefox extension, and I want to
Good Day Everyone... I’m getting an unexpected WCF error complaining of Known Types which
Good day, everyone. I found strange behavior within ASP.NET engine when it handles non-existent
Good day, We just converted our web application .NET 1.1 to .NET 2.0. We
Good day, I'm having a problem with asp.net 2.0 viewstate. Basically, I want to
Good day, In visual studio 2005, when I drop a webcontrol in the designer,
I've spent a good part of the day searching, writing and finally scrapping a
Good morning. I have an XML file which contains lists of warning and errors

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.