http-status-code-404

Why my custom 404 error handler does not work after deployed to web server

百般思念 提交于 2019-12-12 12:12:23
问题 I followed this post and created a global error handler. And I added to handle 404 error myself. however, it works fine when I test locally but once deployed to web server, my custom message is not displaying anymore. Instead, the default ugly one shows up. In remote debug, I can trace the execution and it does get to my custom 404 error action, but somehow, the IIS took over at some point. In my Global.asax.cs, I have: protected void Application_Error() { var exception = Server.GetLastError(

Django display 404 on missing template

孤人 提交于 2019-12-12 10:35:19
问题 I have a website where some pages are edited by hand. When one of those templates is missing, it just means that the page is not present, so I would like to display an Error 404. Instead I get an exception TemplateDoesNotExist. Is there a way to tell Django to display an error 404 whenever it does not find a template? 回答1: If you want this behaviour for all views on your site, you might want to write your own middleware with a process_exception method. from django.template import

Symfony 4 : JS and CSS compiled with Webpack return 404

∥☆過路亽.° 提交于 2019-12-12 10:11:51
问题 I'm building a project with Symfony4 and VueJs, hosted by nginx server and run with Docker. My templates are OK but css and js files are in 404. Here's my nginx configuration : server { listen 80; listen [::]:80; server_name symfony.local; root /var/www/myproject/public; location / { try_files $uri /index.php$is_args$args; } location ~ ^/(index)\.php(/|$) { fastcgi_pass php:9000; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root

How can I catch a 404 status exception thrown by simpleHttp of Http.Conduit

左心房为你撑大大i 提交于 2019-12-12 09:38:27
问题 I'm trying to download all png files contained in an html file. I have trouble catching 404 status exceptions though, instead my program just crashes. Here is some sample to demonstrate: import Network.HTTP.Conduit import qualified Data.ByteString.Lazy as L main = do let badUrl = "http://www.google.com/intl/en_com/images/srpr/WRONG.png" imgData <- (simpleHttp badUrl) `catch` statusExceptionHandler L.writeFile "my.png" imgData statusExceptionHandler :: t -> IO L.ByteString

Openshift app redirecting to https://domain_name/app

不羁岁月 提交于 2019-12-12 09:31:36
问题 I have hosted an app on Redhat Open shift. I didn't change anything but it started redirecting to https://www.plovist.com/app and throwing 404 error. Can anyone help me in solving this? 回答1: Make sure that you have correctly added your alias to your application (www.plovist.com) 回答2: I logged into Godaddy(my DNS) account and found out that in Cnames(Alias) www wasn't pointing to mydjango-plovist.rhcloud.com (URL given by Openshift). Also I pinged mydjango-plovist.rhcloud.com and it gave a

Django: GET css returns 404?

不羁岁月 提交于 2019-12-12 08:59:46
问题 I am developing a Django site and after a series of edits I ran my server again when suddenly - no css! The server still displays the html site, of course, but the css all across the site is throwing a 404 error. My static files information in my settings.py wasn't edited at all: import os # hack to accommodate Windows CURRENT_PATH = os.path.abspath(os.path.dirname(__file__).decode('utf-8')).replace('\\', '/') STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = (

How to specify a custom 404 view for Django using Class Based Views?

北城余情 提交于 2019-12-12 08:27:05
问题 Using Django, you can override the default 404 page by doing this in the root urls.py : handler404 = 'path.to.views.custom404' How to do this when using Class based views? I can't figure it out and the documentation doesn't seem to say anything. I've tried: handler404 = 'path.to.view.Custom404.as_view' 回答1: Never mind, I forgot to try this: from path.to.view import Custom404 handler404 = Custom404.as_view() Seems so simple now, it probably doesn't merit a question on StackOverflow. 回答2:

Custom 404 page - PHP

爷,独闯天下 提交于 2019-12-12 08:23:06
问题 I have a custom 404 page which works fine except for the message I want to display on this page. I would like it to say the url of the page which can't be found but instead it displays the url of the 404 page. Here's what I have... You were looking for <?php echo $_SERVER['REQUEST_URI'] ?>. The htaccess file contains the line: ErrorDocument 404 /404/ 回答1: You need to use $_SERVER['HTTP_REFERER'] instead - that will be the address they requested first. This only works in the exact case

How to handle 404 not found errors in Nokogiri

微笑、不失礼 提交于 2019-12-12 07:50:13
问题 I am using Nokogiri to scrape web pages. Few urls need to be guessed and returns 404 not found error when they don't exist. Is there a way to capture this exception? http://yoursite/page/38475 #=> page number 38475 doesn't exist I tried the following which didn't work. url = "http://yoursite/page/38475" doc = Nokogiri::HTML(open(url)) do begin rescue Exception => e puts "Try again later" end end 回答1: It doesn't work, because you are not rescuing part of code (it's open(url) call) that raises

Custom Django 404 error

柔情痞子 提交于 2019-12-12 07:13:43
问题 I have a 404.html page, but in some cases I want to be able to send a json error message (for 404 and 500, etc.). I read the following page: https://docs.djangoproject.com/en/dev/topics/http/views/#the-404-page-not-found-view Is there any sort of example that shows the implementation? I have it in my urls.py but it's not being picked up in the event of an error. 回答1: This worked for me: from django.conf.urls import patterns, include, url from django.views.static import * from django.conf