PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Dec 19, 2018 10:28 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: php and .htaccess
PostPosted: Tue Oct 07, 2014 5:40 am 
Offline
Forum Newbie

Joined: Tue Oct 07, 2014 5:23 am
Posts: 2
Hi,
I'm totally new to making web pages and have a small site (http://www.mazzocco.dk) where I have a few things located that people can download.
I've made a folder there called "Sheila" that I have protected with a .htaccess file and.htpasswd file I made. Now the question is:
How do I go about displayinging my custom 401page.php?
I don't just want the "normal" error page to display, but my own made page, when people type in the wrong user name/password
My .htaccess file:
AuthName "User Name And Password"
AuthType Basic
AuthUserFile /customers/0/4/f/mazzocco.dk/httpd.www/Sheila/.htpasswd
AuthGroupFile /dev/null
require valid-user

I want it to display this file when wrong information is entered:
<html>
<head>
<meta http-equiv="refresh" content="3; URL=http://mazzocco.dk/">
<meta name="keywords" content="automatic redirection">
</head>
<body>
<center><font size="+2">Restircted area<BR>
If your browser doesn't automatically return you<BR>
to the main page within a few seconds you may want<BR>
to go to <a href="http://mazzocco.dk/">the destination</a>
manually.</font></center>
<center><img src="access.jpg"</img></center>
</body>
</html>

But I want it to make a directory listing from my normal index.php file (like it looks in all the non-password protected folders) when the right information is entered in the authentication box that is displayed.
In case it cannot be done, what do I need to type in my .htaccess file for it to display a message that I make when wrong information is entered?

Thanks in advance and sorry if this is the wrong place to ask such a question but I've exhausted my web searches and they didn't turn up the information I needed


Top
 Profile  
 
 Post subject: Re: php and .htaccess
PostPosted: Tue Oct 07, 2014 7:12 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6424
Location: Montreal, Canada
Have you added an ErrorDocument directive to your .htaccess?

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
 Post subject: Re: php and .htaccess
PostPosted: Wed Oct 08, 2014 11:23 pm 
Offline
Forum Newbie

Joined: Tue Oct 07, 2014 5:23 am
Posts: 2
I have tried that yes,
ErrorDocument 401 /Sheila/401page.php
This only results in the page not loading at all. Sorry I didn't mention that earlier.
If you have other suggestions I'm all ears (eyes in this case :))


Top
 Profile  
 
 Post subject: Re: php and .htaccess
PostPosted: Wed Oct 08, 2014 11:41 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
I don't know what all Apache will do when serving the 401 page, but at best you simply need to send a 401 Unauthorized header - that's what triggers the username/password dialog. Otherwise PHP will send its own 200 OK, that it normally does, and the browser won't know what to do.
Syntax: [ Download ] [ Hide ]
header("HTTP/1.1 401 Unauthorized");


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group