Forum Moderators: open

Message Too Old, No Replies

Capturing HTTP-401

Reformatting "Authorisation required"

         

technossomy

11:54 am on Dec 29, 2004 (gmt 0)

10+ Year Member



I am developing a site where I want to capture the 401 error, the page the browser throws up where it says "Authorisation required". The style of this page is default HTML. The question is, how do I give it my own style?

My provider tells me there is nothing one can do, because it is a client side exception. However, with some famous companies if I type
http://www.example.com/nonsense/nonsense.html
I get a 404 and in the style of the famous company's website.

What are these companies doing that they make it so?

[edited by: tedster at 3:54 pm (utc) on Dec. 29, 2004]
[edit reason] use example.com [/edit]

rocknbil

4:38 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this a Linux server? Put this in a plain text file

ErrorDocument 401 /auth_failed.html

Save the file as .htaccess. Upload it to the root of your server. Now create your auth_failed.html, a custom error page.

You must get the auth_failed.html file size up over 512 bytes or Internet Explorer will ignore it and display "friendly error messages." You can't just link to an image to increase size, it has to be the file itself. Populate the bottom of the page with text or comments until it's over 512 bytes.

tedster

5:15 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For IIS, here's the Microsoft page for custom error messages [microsoft.com].

DRock80

11:13 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



If it's an Apache server you will be able to trap errors using .htaccess files (search google for details). If your not immediately clear after reading tutorials on how to use .htaccess, you should work with your provider to ensure the file is going to do what you think it will. You can really mess up your access to files if you put something incorrect in the .htaccess file.

If it's an IIS server I believe you will need the hosting company to help you out (unless you have access to IIS settings). You need them to define a custom error page for that specific error. This is simple to do for IIS admins, but it's possible your hosting company may not allow custom errors.

If it's an IIS server that supports ASP.NET applications you MAY be able to trap this error using a setting in the web.config file. I don't have any experience with this though...