http-status-code-404

How to properly setup custom handler404 in django?

匆匆过客 提交于 2019-12-22 03:23:02
问题 According to the documentation this should be fairly simple: I just need to define handler404 . Currently I am doing, in my top urls.py : urlpatterns = [ ... ] handler404 = 'myapp.views.handle_page_not_found' The application is installed. The corresponding view is just (for the time being I just want to redirect to the homepage in case of 404): def handle_page_not_found(request): return redirect('homepage') But this has no effect: the standard (debug) 404 page is shown. The documentation is a

AngularJS SEO Page 404 Header Status Code

岁酱吖の 提交于 2019-12-21 21:28:45
问题 We are working in a project which uses Symfony2 + AngularJS. Each one in a different domain (api.domain for Symfony2 and www.domain for the Angular project). Now we are focusing on the SEO part. We use Prerender.io to create static snapshots to serve a good HTML Raw page to crawlers. But the problem is when serving the "404 Page" on Angular: $urlRouterProvider .otherwise('/404'); The thing is, what we do is redirecting a nonexistent page to our "404 Page" with a 200 Header Status Code, which

Mechanize/Ruby read source code of 404 page

ぐ巨炮叔叔 提交于 2019-12-21 20:54:40
问题 All I'm doing is loading mechanize, and getting a page that returns 404. But that's exactly what I want. The 404 page has plenty of html I'd like to use in my example. a = mechanize.new a.get('http://www.youtube.com/watch?v=e4g8jriw4rg') a.page => nil I can't seem to find any further info on this. 回答1: You need to handle the exception: begin page = a.get 'http://www.youtube.com/watch?v=e4g8jriw4rg' rescue Mechanize::ResponseCodeError => e puts e.response_code # the status code as a string, e

Scrapy:In a request fails (eg 404,500), how to ask for another alternative request?

大城市里の小女人 提交于 2019-12-21 04:33:07
问题 I have a problem with scrapy. In a request fails (eg 404,500), how to ask for another alternative request? Such as two links can obtain price info, the one failed, request another automatically. 回答1: Use "errback" in the Request like errback=self.error_handler where error_handler is a function (just like callback function) in this function check the error code and make the alternative Request. see errback in the scrapy documentation: http://doc.scrapy.org/en/latest/topics/request-response

What happens when i put a slash (/) after a .php url?

狂风中的少年 提交于 2019-12-21 04:17:08
问题 I have a simple question, but could not find the answer anywhere say I have a site "mysite.com". I can access the index page by either typing "mysite.com" or "mysite.com/index.php". This works fine... however, when i try to go to "mysite.com/index.php/" the page loads, but not correctly. what is exactly happening? I would think it should return a 404 error, since index.php would be treated as a (non existing) directory (i.e. i would think it would try to find "mysite.com/index.php/index.php")

web.config errors fail with responseMode=“File”

浪子不回头ぞ 提交于 2019-12-21 03:58:07
问题 According to Microsoft's documentation, for static (i.e. HTML) content, web.config should read responseMode="File" for each error. Currently, my web.config includes <httpErrors errorMode="Custom"> <!-- remove statusCodes --> <error statusCode="404" path="/error/404.html" responseMode="ExecuteURL" /> </httpErrors> This returns the correct custom error page, but returns a 200 OK status code. When I change "ExecuteURL" to "File", my server does return a 404, but the custom error page is not

MVC 4 - LogOff controller action giving 404 not found

被刻印的时光 ゝ 提交于 2019-12-21 03:31:43
问题 I'm just wrapping up a college project, I'm not sure if I've been staring at my computer for too long and am missing something obvious, but when I try to log a user out, I'm getting a 404 not found for the URL /Account/LogOff. I have a navbar that shows Log in/Log out depending on whether a user is, logged in, or, logged out: <div class="nav-collapse collapse"> <ul class="nav pull-right"> <li class="dropdown" id="dropdown-login-div"> @if (!Request.IsAuthenticated) { <a class="dropdown-toggle"

Send a 404 error via htaccess?

徘徊边缘 提交于 2019-12-21 03:13:12
问题 I'd like to cut off access to a subdirectory on my site but I want any access in the subdirectory to be a 404 error, not a 403 forbidden. How can this be accomplished? 回答1: Try: RewriteRule ^directory/ - [L,R=404] This redirects all requests for the folder " /directory/ ", they get a 404 response. 回答2: You could also for the time being change which page a user will see when confronted with a 403 error, but I wouldn't recommend doing this long-term. .htaccess: ErrorDocument 403

404 not found page not working with my .htaccess

对着背影说爱祢 提交于 2019-12-21 02:44:32
问题 I have below .htaccess on the server with the not found page rules but it doesn't seems to work. Any idea? RewriteEngine on RewriteRule ^article_detail/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ article_detail.php?article_det=$2 Options +FollowSymLinks ErrorDocument 404 http://www.example.com/main/404_not_found.html # compress text, HTML, JavaScript, CSS, and XML <IfModule mod_ext_filter.c> AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE

Redirect to 404 page programmatically using asp.net MVC

ⅰ亾dé卋堺 提交于 2019-12-20 18:34:17
问题 I have created a Asp.net MVC application. Now required 404 handling. Have updated global.asax and display 404 page based on status code. Also added customErrors property in web.config. Its working fine. Now I would like to redirect to 404 programmatically when any thing not match with our requirement. i.e. if(!valid) { return RedirectToAction("Index", "Page404"); } It's working fine but there are 2 status one is 301 & then 404. So how can I prevent 301? I just need 404. How can I achieve this