http-status-code-404

How to display the message passed to Http404 in a custom 404 Error template in Django?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 02:43:40
问题 I have a project that I am working on in django. There are a lot of instances where I: raise Http404("this is an error") and it creates a nice 404 page for me with the error message "this is an error" written on it. I now want to create a custom error page and have it still display the message, but I can't figure out how. I'm sure it's just a template variable that I need to add to my custom 404 template, but I can't find any documentation for it. 回答1: As of Django 1.9, the exception is

Getting a 404 when using .NET 4 on IIS 6, with or without MVC

陌路散爱 提交于 2019-11-28 02:39:03
问题 I've completed this set up on a fair few IIS 6 boxes, but one is giving me a tough time. The problem occurs when I add the application extension mapping to: c:\windows\microsoft.net\framework\v4.0.21006\aspnet_isapi.dll When this is in place, I get a 404 error on every request. Even if I remove all files from the application directory apart from a basic test.htm and navigate to that, I still get a 404. I've unchecked the "Verify that file exists" I've set up a .NET 4 application pool and

Forbidden Error 403 On Server Folder

吃可爱长大的小学妹 提交于 2019-11-28 02:28:16
I'm trying to host a new blog where I can add posts using a simple HTML form & PHP script. When I test out the form on my localhost everything works fine, but when I upload it and test it live I get: Forbidden You don't have permission to access /php/add-post.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I know that my host allows this type of script because I'm using exactly the same thing on another blog, and my permissions are set to 0755 . Does anyone know what the problem might be & how to solve it? 来源:

Configuring custom ASP 404 page with redirect for IIS7 website

折月煮酒 提交于 2019-11-28 02:10:26
We're migrating an existing website from IIS6 to IIS7, but are experiencing some difficulty in setting up the 404 error page. Our 404-errorpage works like this: A custom ASP-page checks the URL against a short list of 'special' URLs (e.g. http://example.com/limited-offers ). If the URL is known, it redirects to the actual URL of that page. Otherwise the visitor is redirected to a static errorpage with a 404-statuscode. With IIS6 this worked as advertised, but with IIS7 some things have changed. IIS7 will always display the configured errorpage when it encounters a statuscode for which an

mod rewrite to remove file extension, add trailing slash, remove www and redirect to 404 if no file/directory is available

穿精又带淫゛_ 提交于 2019-11-28 02:04:47
问题 I would like to create rewrite rules in my .htaccess file to do the following: When accessed via domain.com/abc.php: remove the file extension, append a trailing slash and load the abc.php file. url should look like this after rewrite: domain.com/abc/ When accessed via domain.com/abc/: leave the url as is and load abc.php When accessed via domain.com/abc: append trailing slash and load abc.php. url should look like this after rewrite: domain.com/abc/ Remove www Redirect to 404 page (404.php)

How can I catch a 404?

我是研究僧i 提交于 2019-11-28 01:47:43
I have the following code: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "HEAD"; request.Credentials = MyCredentialCache; try { request.GetResponse(); } catch { } How can I catch a specific 404 error? The WebExceptionStatus.ProtocolError can only detect that an error occurred, but not give the exact code of the error. For example: catch (WebException ex) { if (ex.Status != WebExceptionStatus.ProtocolError) { throw ex; } } Is just not useful enough... the protocol exception could be 401, 503, 403, anything really. Use the HttpStatusCode Enumeration ,

getting java.io.IOException: HTTP request failed, HTTP status: 404 in ksoap2 while passing xml data to soap1.2 android

a 夏天 提交于 2019-11-28 00:31:32
i have to pass <?xml version='1.0' encoding='utf-8' ?> <hello><username>test@test.com</username> <password>test</password></hello> to Wsdl <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"

How to callback a function on 404 in JSON ajax request with jQuery?

梦想的初衷 提交于 2019-11-27 23:30:23
I want to make an Ajax request with response in JSON. So I made this Ajax request: $.ajax({ url: 'http://my_url', dataType: "json", success: function(data){ alert('success'); }, error: function(data){ alert('error'); }, complete: function(data) { alert('complete') }}) This code works good but when my url send me a HTTP code 404, no callbacks are used, even the complete callback. After research, it's because my dataType is 'json' so 404 return is HTML and the JSON parsing failed. So no callback. Have you a solution to call a callback function when a 404 is raised ? EDIT: complete callback don't

Custom 404 error page — for PHP pages only

荒凉一梦 提交于 2019-11-27 22:30:53
问题 I have a personalized page for 404 with htaccess ErrorDocument 404 /404.php It works fine, but it takes everything .jpg, .js, .css etc... I would like it to just take the .php and do a normal 404 error for all others. I didn't find that option anywhere. Thank you very much. 回答1: Not sure but give this a try: <Files ~ "\.php$"> ErrorDocument 404 /404.php </Files> Quote from Files Directive documentation: The <Files> directive limits the scope of the enclosed directives by filename. 回答2: There

flask: error_handler for blueprints

99封情书 提交于 2019-11-27 22:02:54
问题 Can error_handler be set for a blueprint? @blueprint.errorhandler(404) def page_not_found(error): return 'This page does not exist', 404 edit: https://github.com/mitsuhiko/flask/blob/18413ed1bf08261acf6d40f8ba65a98ae586bb29/flask/blueprints.py you can specify an app wide and a blueprint local error_handler 回答1: You can use Blueprint.app_errorhandler method like this: bp = Blueprint('errors', __name__) @bp.app_errorhandler(404) def handle_404(err): return render_template('404.html'), 404 @bp