http-status-code-404

In a single-page app, what is the right way to deal with wrong URLs (404 errors)?

有些话、适合烂在心里 提交于 2019-11-30 04:11:13
I am currently writing a web application using angularjs, but I think this question applies to any client-side javascript framework that does routing on the client side ( as angular does ). In a single-page app, what is the right way to deal with wrong URLs? Looking at a few major sites, I see that gmail will redirect to the inbox if you type any random URL below https://mail.google.com/mail/ . This happens server-side (with an http 300 code) or client-side, depending on whether the wrong path is before or after the # character. On the other hand, twitter shows a real HTTP 404 for any invalid

404 page in REACT

落花浮王杯 提交于 2019-11-30 03:55:11
问题 I created the component NotFound and it works fine when I go to a page that doesn't exist. But the same page it's appearing in all my pages, not only the one that doesn't exist. This is the component: import React from 'react' const NotFound = () => <div> <h3>404 page not found</h3> <p>We are sorry but the page you are looking for does not exist.</p> </div> export default NotFound And this is how I used it in the main page: class MainSite extends Component { render () { return ( <div> {/*

Laravel: How to respond with custom 404 error depending on route

梦想的初衷 提交于 2019-11-30 03:53:50
I'm using Laravel4 framework and I came across this problem. I want to display a custom 404 error depending on requested url. For example: Route::get('site/{something}', function($something){ return View::make('site/error/404'); }); and Route::get('admin/{something}', function($something){ return View::make('admin/error/404'); }); The value of '$something' is not important. Shown example only works with one segment, i.e. 'site/foo' or 'admin/foo' . If someone request 'site/foo/bar' or 'admin/foo/bar' laravel will throw default 404 error. App::missing(function($exception){ return '404: Page Not

Angular 2 Hosted on IIS: HTTP Error 404

时光怂恿深爱的人放手 提交于 2019-11-30 03:50:31
I have simple app with one component that expects certain parameters from url. there is only one route in the application: const appRoutes: Routes = path: 'hero/:userId/:languageId',component: HeroWidgetComponent }]; In the Index.html, I have this in the header <base href="/"> I am using webpack and the application runs fine on development environment, when browsing the url: http://localhost:4000/hero/1/1 . However, when building the app for production and getting the distribution files, then hosting that on IIS. I get the following Error when trying to browse the same url: HTTP Error 404.0 -

How I return HTTP 404 JSON/XML response in JAX-RS (Jersey) on Tomcat?

微笑、不失礼 提交于 2019-11-30 00:55:21
问题 I have the following code: @Path("/users/{id}") public class UserResource { @Autowired private UserDao userDao; @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public User getUser(@PathParam("id") int id) { User user = userDao.getUserById(id); if (user == null) { throw new NotFoundException(); } return user; } If I request for a user that doesn't exists, like /users/1234 , with " Accept: application/json ", this code returns an HTTP 404 response like one would expect,

django heroku media files 404 error

…衆ロ難τιáo~ 提交于 2019-11-29 23:21:38
问题 I recently deployed a Django app to Heroku and uploaded some media files and everything seemed to work fine, until yesterday when i tried to access the application again and saw that it was giving a 404 error. Any ideas why this is happening? settings.py: import os BASE_DIR = os.path.abspath(os.path.dirname(__file__)) import dj_database_url #DATABASES['default'] = dj_database_url.config() DATABASES = {'default': dj_database_url.config(default='postgres://localhost')} # Honor the 'X-Forwarded

LESS file does not load (404)

有些话、适合烂在心里 提交于 2019-11-29 21:15:33
I'm using IIS 7.5 and I'm unable to load the less file because it gives a 404 error. HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Less Tutorial</title> <link rel="stylesheet/less" href="style.less" /> <script src="less-1.0.41.min.js"></script> </head> <body> <div id="container"> <a href="#">My Anchor</a> </div> </body> </html> LESS: @primary_color: green; #container { width: 200px; height: 200px; background: @primary_color; } When using Asp.Net you can add the mime type in your web.config: <system.webServer> <staticContent> <mimeMap fileExtension=".less"

NSError * domain: @“com.google.HTTPStatus” - code: 404

狂风中的少年 提交于 2019-11-29 17:36:27
I am trying to read images from Firebase storage, and I am getting this error: NSError * domain: @"com.google.HTTPStatus" - code: 404 In function: - (void)invokeFetchCallbacksOnCallbackQueueWithData:(GTM_NULLABLE NSData *)data error:(GTM_NULLABLE NSError *)error { // Callbacks will be released in the method stopFetchReleasingCallbacks: GTMSessionFetcherCompletionHandler handler; @synchronized(self) { GTMSessionMonitorSynchronized(self); handler = _completionHandler; if (handler) { [self invokeOnCallbackQueueUnlessStopped:^{ handler(data, error); // Post a notification, primarily to allow code

Symfony2 logging 404 errors

余生长醉 提交于 2019-11-29 15:48:53
问题 I need to be able to log/receive an email when a 404 error occurs. I can see in the docs how to set up a new template for these errors, but how do I catch them in the first place in my controller so that I can implement the logging/emailing logic? 回答1: Maybe adding an event listener listening for the kernel.exception event would do it? Check out http://symfony.com/doc/current/book/internals.html#kernel-exception-event along with http://symfony.com/doc/current/reference/dic_tags.html#dic-tags

PHP: prevent direct access to page

跟風遠走 提交于 2019-11-29 15:22:29
I have some pages that I don't want users to be able to access directly. I have this function I came up with which works: function prevent_direct_access() { if($_SERVER['REQUEST_URI'] == $_SERVER['PHP_SELF']) { //include_once('404.php'); header("Location: 404.php"); } } This does exactly what I want, the URL does not change but the content does. However I am wondering if there is something I need to add to tell search engines that this is a 404 and not to index it. keep in mind I do not want the URL to change though. Thanks! Don’t redirect but send the 404 status code: header($_SERVER['SERVER