Safari ignores ErrorDocument 401 redirects

Hello,

I have a website with a few directories, the contents of which are protected with .htaccess files. If an unauthorized user attempts to view the contents, they are redirected to an error page. The line in my htaccess file to do that looks like this:

ErrorDocument 401 /unauthorized.php

Every browser behaves as expected except Safari. Safari just stays on the original referring page and doesn't do anything. It completely ignores the directive in the htaccess file? I've googled this and found that this may be a issue with how Safari handles redirects to php pages but that was from 2004 and it seems like Apple hasn't fixed the problem.

It happens with every version of Safari for any Mac OS. I've never tried the Windows version

Unfortunately, I have to use a php page in order to get info about the user (IP address, what page they are trying to view, purchasing options)

Does anybody else have any idea how I can solve this?

Posted on Mar 19, 2009 7:04 AM

Reply
6 replies

Apr 7, 2009 4:31 AM in response to iBod

Okay, good idea.

If you go to http://chillmost.com/getin.html and click the link, you will find that the directory is restricted.

If you enter a valid name and password you get in. If you don't and click "Cancel", you should then be redirected to a page that, in this case, just displays a short message and your IP address.

In Firefox and other browsers, this works the way it is supposed to. In Safari, when you click cancel, you just stay on the original page.

Strange, no?

Apr 7, 2009 5:02 AM in response to Nathan Russell

Hi Nathan,

Well I can duplicate what you see. Can you post the rest of the .htaccess file here (or to http://pastebin.com) to see if there might be something there causing the problem.

Edit: Actually, I just tried the same type of thing on my broadband router admin page and that also stays on the current page when clicking Cancel on the authorisation request. So, it looks like it might be a genuine bug with Safari.

And a further update:

https://bugs.webkit.org/show_bug.cgi?id=6871

Looks like the WebKit guys have known about it for a while. Maybe you should chime in on that bug report to see if there's any new news?

Apr 7, 2009 8:17 AM in response to iBod

Yeah, actually I remember seeing this page years ago. Strange that it hasn't been fixed yet. So I guess that's it then. Just have to wait for an update to webkit.

Code is...
in .htaccess in protected directory:

AuthType Basic
AuthName "Get In"
AuthUserFile /path/to/password/file/pass.pw
require valid-user
Satisfy any
order deny,allow
allow from xxx.xxx.xxx.xxx
deny from all




in htaccess at root of site:

ErrorDocument 401 /unauthorized.php

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Safari ignores ErrorDocument 401 redirects

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.