/    Sign up×
Community /Pin to ProfileBookmark

htaccess, htpasswd – making a login form / screen

Hi,

I want to add a password protected directory using .htaccess / .htpasswd.

This i can do, but what I’d like is to be able to make a login page rather than the little browser window that pops up asking for the username & password.

Does anyone know if this is possible to do, to be able to add a form to a page that would log in and accept the user/pass ? If so, please help !

What would the form need to say ?

Thanks in advance for any suggestions.
Gavioli

to post a comment
HTML

10 Comments(s)

Copy linkTweet thisAlerts:
@ryguillianOct 04.2005 — Unfortunately, .htaccess uses the HTTP security mechanism. If you somehow want access control using a 'login page' then you're going to need to use a more sophisticated tool like PHP. However, .htaccess is not the route you're going to take to accomplish this.
Copy linkTweet thisAlerts:
@plabebobOct 05.2005 — i just read your post and noticed that you said you know how to make a password box pop up......i've been trying to fugure out how to do that for ages!

can you pm me how you do it..or point me in the direction of a useful tutorial or something?

much appreciated

plabebob.
Copy linkTweet thisAlerts:
@konithomimoOct 05.2005 — gavilioli, here is a way that allows you to have a login box embedded in your web page for pages that are normally only available through a pop up dialogue box.

<i>
</i>&lt;!-- STEP ONE: Paste this code into the HEAD of your HTML document --&gt;

&lt;HEAD&gt;

&lt;SCRIPT LANGUAGE="JavaScript"&gt;

&lt;!-- Begin
function Login(form) {
var username = form.username.value;
var password = form.password.value;
var server = form.server.value;
if (username &amp;&amp; password &amp;&amp; server) {
var htsite = "http://" + username + ":" + password + "@" + server;
window.location = htsite;
}
else {
alert("Please enter your username and password.");
}
}
// End --&gt;
&lt;/script&gt;

&lt;/HEAD&gt;

&lt;!-- STEP TWO: Copy this code into the BODY of your HTML document --&gt;

&lt;BODY&gt;

&lt;!-- The hidden form field "server" needs to be the
address of your password protected directory. --&gt;

&lt;form name=login&gt;
&lt;input type="hidden" name="server" value="www.domain.com/secure/"&gt;
Username:
&lt;input type=text name=username size=20&gt;
&lt;br&gt;&lt;br&gt;
Password:
&lt;input type=password name=password size=20&gt;
&lt;input type=button value="Login!" onClick="Login(this.form)" name="button"&gt;
&lt;/form&gt;


Copy linkTweet thisAlerts:
@gavioliauthorOct 05.2005 — Hi Guys,

Thanks for your comments & help.

It looks like php is the way.

That script that you gave, konithomimo, unfortunately is no good for my application and won't work for me, but thanks anyway.

Gavioli
Copy linkTweet thisAlerts:
@gavioliauthorOct 07.2005 — Hi,

It's a tricky thing to figure, until you know how and what to use, then really simple !!

I couldn't get it to work, until I found this tutorial - http://help.bnsi.net/htpasswd/htpasswd.php

First of all, your host must be able to let you upload .htaccess & .htpasswd files. If you can't do this through ftp, then you simply won't be able to do it. The only simple way to pass protect is via java script - but of course any hacker can get past that.

If you can upoload these files, then have a look at that link and you must download the htpasswd.exe. Without this programme, you can't make the file in the correct format.

I read on loads of pages where people say write a text file, then just rename it, but that is fine for the .htacess, but the .htpasswd is the important thing and without that programme, a simple text editor won't save it right and it'll never work.

If you need any more help or info, drop me a message.

regards,

gavioli
Copy linkTweet thisAlerts:
@konithomimoOct 07.2005 — To create a .htaccess file all you need is a text editor such as notepad. Just save the file as .htaccess.txt, then upload it and rename it .htaccess

You don't need any special programs to create access files.
Copy linkTweet thisAlerts:
@gavioliauthorOct 20.2005 — .htaccess is fine in a text editor, but without htpasswd.exe, I couldn't make that file (.htpasswd) work

I'm not sure why, but if you make the .htpasswd file in a text editor, it just doesn't work right.
Copy linkTweet thisAlerts:
@xkipxDec 10.2005 — Do you know the code to use for secure to make it from the server eg. /home/public_html/etc instead of http://www.blah.com/secure

?
Copy linkTweet thisAlerts:
@srbrodzikDec 13.2017 — I know this is an old post so that might explain why the link http://help.bnsi.net/htpasswd/htpasswd.php does not work. This is something I'm trying to do and looking for some guidance.
Copy linkTweet thisAlerts:
@rootDec 14.2017 — Please do not resurrect old posts.

** closed **
×

Success!

Help @gavioli spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...