htaccess: ErrorDocument & Authorization (Apache)

This is a discussion on htaccess: ErrorDocument & Authorization (Apache) within the Linux Web Servers forums, part of the Web Server and Related Forums category; I've got a directory setup that looks like this: /Public .htaccess public.shtml /Private .htaccess .htpasswd private.shtml /Public/....


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-21-2005
Eric
 
Posts: n/a
Default htaccess: ErrorDocument & Authorization (Apache)

I've got a directory setup that looks like this:

/Public
.htaccess
public.shtml
/Private
.htaccess
.htpasswd
private.shtml


/Public/.htaccess looks like:

ErrorDocument 401 /Public/public.shtml


/Public/Private/.htaccess looks like:

AuthName "section"
AuthType Basic
AuthUserFile /Public/Private/.htpasswd
Require valid-user


So, if I enter:

http://domain.com/Public/Private/private.html

it my browser, I see in the access log a 401 response code and the
authorization dialog appears. If I press the cancel buton, the
authorization dialog appears again and I press the cancel button again.
At this point, the ErrorDocument appears, but the URL in the browser
still shows:

http://domain.com/Public/Private/private.shtml

If I do not specify an ErrorDocument, after I press the cancel button
for the first time, the URL in the browser shows:

http://domain.com/Public/Private/private.shtml

I do not get two authorization dialogs and the default apache error page
shows.

What I would like to have happen is for the browser to be redirected to:

http://domain.com/Public/public.shtml

after the cancel button is pressed the first time.

Any hints on how to make this happen?
  #2 (permalink)  
Old 04-22-2005
Eric
 
Posts: n/a
Default Re: htaccess: ErrorDocument & Authorization (Apache)

Well, after playing around with this some more, I found a solution which
I believe to be acceptable.

The ErrorDocument now points to a .html document which has the following
basic form (a couple of details removed):


<html>
<head>
<title>Not Authorized</title>
<meta http-equiv="Refresh" content="15; URL=/Public/notauthorized.html">
</head>
<body bgcolor="#FFFFFF">
<p>I'm sorry, but a valid username and password was not entered. The
browser will now be redirected back to the main downloads page where a
request can be made for a valid username and password. If the browser is
not redirected within a few seconds, please click on the link below.
</p>
</body>
</html>


Basically, it just brings up an error pages which let's the user know
what happened and then redirects the user back to a page they are
allowed to access after 15 seconds.

A solution I had tried before what to point ErrorDocument at a page that
looked like:


<?PHP header( "Location: /Public/public.shtml"); ?>


but this just resulted in the redirect taking place immediately before
the user was allowed to enter a name and password.
Edit/Delete Message
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:22 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0