Seo Forum

Search Engine Optimization => SEO Basics => Topic started by: Ruhikhan862 on 11-07-2016, 00:48:13

Title: how to solve 404 error ?
Post by: Ruhikhan862 on 11-07-2016, 00:48:13
Hello friends,

Please tell me,how to solve 404 error ?
Title: Re: how to solve 404 error ?
Post by: Lund SEO on 11-07-2016, 18:52:49
A 404 error typically occurs when a webpage or file you are trying to access cannot be found on the server. To solve a 404 error, here are a few steps you can follow:

1. Refresh the page: Sometimes, a 404 error can occur due to a temporary glitch. Try refreshing the page to see if the error resolves itself.

2. Double-check the URL: Make sure you have typed the correct URL in the address bar. Even a small typo can result in a 404 error.

3. Clear your browser cache: Cached files can sometimes cause issues when accessing certain webpages. Clear your browser cache and try accessing the page again.

4. Check for broken links: If you are encountering a 404 error when clicking on a link from another website, it's possible that the link is broken. Contact the website owner to inform them of the issue.

5. Check server configuration: If you are a website owner, ensure that the webpage or file you are trying to access is properly uploaded to your server and that the server configuration is correct.

Here are a few examples of handling a 404 error code in different programming languages:

1. Python:
```python
from flask import Flask, abort

app = Flask(__name__)

@app.route('/your_route')
def your_route():
    abort(404)

@app.errorhandler(404)
def page_not_found(e):
    return "404 Error - Page not found", 404

if __name__ == '__main__':
    app.run()
```

2. JavaScript (Node.js):
```javascript
const express = require('express');
const app = express();

app.get('/your_route', (req, res) => {
    res.status(404).send('404 Error - Page not found');
});

app.listen(3000, () => {
    console.log('Server running on port 3000');
});
```

3. PHP:
```php
<?php
http_response_code(404);
echo "404 Error - Page not found";
?>
```

4. Java (using Spring Boot framework):
```java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.NoHandlerFoundException;

@SpringBootApplication
@RestController
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @RequestMapping("/your_route")
    public void yourRoute() throws NoHandlerFoundException {
        throw new NoHandlerFoundException("GET", "/your_route", null);
    }

    @RequestMapping("/error404")
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public String handle404Error() {
        return "404 Error - Page not found";
    }
}
```

5. Ruby (using Sinatra framework):
```ruby
require 'sinatra'

get '/your_route' do
    status 404
    "404 Error - Page not found"
end
```

6. C# (using ASP.NET Core):
```csharp
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers();
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseRouting();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllerRoute(
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}");
        });

        app.Run(async (context) =>
        {
            context.Response.StatusCode = 404;
            await context.Response.WriteAsync("404 Error - Page not found");
        });
    }
}
```

7. Rust (using Rocket framework):
```rust
#[macro_use] extern crate rocket;

use rocket::Request;
use rocket::response::content;

#[get("/your_route")]
fn your_route() -> content::Html<&'static str> {
    content::Html("<h1>404 Error - Page not found</h1>")
}

#[catch(404)]
fn not_found(req: &Request<'_>) -> content::Html<&'static str> {
    content::Html("<h1>404 Error - Page not found</h1>")
}

#[launch]
fn rocket() -> _ {
    rocket::build()
        .mount("/", routes![your_route])
        .register("/", catchers![not_found])
}
```

8. Swift (using Vapor framework):
```swift
import Vapor

struct YourRouteController: RouteCollection {
    func boot(routes: RoutesBuilder) throws {
        routes.get("your_route", use: handleNotFound)
    }

    func handleNotFound(req: Request) throws -> EventLoopFuture<String> {
        throw Abort(.notFound, reason: "404 Error - Page not found", identifier: nil)
    }
}

struct ErrorMiddleware: Middleware {
    func respond(to request: Request, chainingTo next: Responder) -> EventLoopFuture<Response> {
        return next.respond(to: request).flatMapError { error in
            if let abort = error as? AbortError, abort.status == .notFound {
                return request.eventLoop.makeSucceededFuture(Response(status: .notFound, body: "404 Error - Page not found"))
            } else {
                return request.eventLoop.makeFailedFuture(error)
            }
        }
    }
}

let app = Application()
app.middleware.use(ErrorMiddleware())
try app.register(collection: YourRouteController())
try app.run()
```

9. Kotlin (using Ktor framework):
```kotlin
import io.ktor.application.*
import io.ktor.features.StatusPages
import io.ktor.http.HttpStatusCode.Companion.NotFound
import io.ktor.response.respond
import io.ktor.routing.Routing
import io.ktor.routing.get

fun Application.module() {
    install(Routing) {
        get("/your_route") {
            throw NotFoundException()
        }
    }

    install(StatusPages) {
        exception<NotFoundException> {
            call.respond(NotFound, "404 Error - Page not found")
        }
    }
}
```

10. JavaScript (using Express.js framework):
```javascript
const express = require('express');
const app = express();

app.get('/your_route', (req, res, next) => {
    const err = new Error('Not Found');
    err.status = 404;
    next(err);
});

app.use((err, req, res, next) => {
    res.status(err.status || 500);
    res.send('404 Error - Page not found');
});

app.listen(3000, () => {
    console.log('Server running on port 3000');
});
```

11. PHP (using Symfony framework):
```php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Exception\NoConfigurationException;

$request = Request::createFromGlobals();
$routes = new \Symfony\Component\Routing\RouteCollection();
$routeName = 'your_route';

$routes->add($routeName, new \Symfony\Component\Routing\Route('/your_route'));
$context = new \Symfony\Component\Routing\RequestContext();
$matcher = new \Symfony\Component\Routing\Matcher\UrlMatcher($routes, $context);

try {
    $parameters = $matcher->match($request->getPathInfo());
} catch (NoConfigurationException $exception) {
    $response = new Response('404 Error - Page not found', 404);
    $response->send();
    return;
}

// Your route handling logic here
```

12. Ruby (using Sinatra framework):
```ruby
require 'sinatra'

get '/your_route' do
    status 404
    "404 Error - Page not found"
end

not_found do
    status 404
    "404 Error - Page not found"
end
```

13. TypeScript (using NestJS framework):
```typescript
import { HttpStatus, NotFoundException } from '@nestjs/common';
import { Controller, Get, NotFoundExceptionFilter, UseFilters } from '@nestjs/common';

@Controller()
export class AppController {
    @Get('your_route')
    notFoundRoute() {
        throw new NotFoundException();
    }

    @UseFilters(new NotFoundExceptionFilter())
    async handleNotFound() {
        return {
            statusCode: HttpStatus.NOT_FOUND,
            message: '404 Error - Page not found',
        };
    }
}
```

14. Perl (using Dancer2 framework):
```perl
use Dancer2;
get '/your_route' => sub {
    status 'not_found';
    return "404 Error - Page not found";
};

Dancer2->to_app;
```

15. Bash (using CGI script):
```bash
#!/bin/bash

echo "Content-type: text/html"
echo ""
echo "<html><body>"
echo "<h1>404 Error - Page not found</h1>"
echo "</body></html>"
```

16. Dart (using Flutter):
```dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      onGenerateRoute: (RouteSettings settings) {
        return MaterialPageRoute(
          builder: (BuildContext context) {
            return Scaffold(
              body: Center(
                child: Text(
                  '404 Error - Page not found',
                  style: TextStyle(fontSize: 20.0),
                ),
              ),
            );
          },
        );
      },
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Home')),
      body: Center(
        child: RaisedButton(
          onPressed: () {
            Navigator.pushNamed(context, '/your_route');
          },
          child: Text('Go to non-existent route'),
        ),
      ),
    );
  }
}
```

17. Lua (using OpenResty/Nginx server):
```lua
location /your_route {
    return 404 "404 Error - Page not found";
}

error_page 404 = @404;

location @404 {
    content_by_lua_block {
        ngx.say("404 Error - Page not found")
    }
}
```

18. PowerShell (using ASP.NET Core):
```powershell
$ErrorActionPreference = 'Stop'

$Handler = {
    param($HttpContext)
    $HttpContext.Response.StatusCode = 404
    $HttpContext.Response.WriteAsync("404 Error - Page not found")
}

Add-Type -TypeDefinition @"
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;

public class Startup
{
    public void Configure(IApplicationBuilder app)
    {
        app.Use((context, next) =>
        {
            context.Response.OnStarting(state =>
            {
                var httpContext = (HttpContext)state;
                httpContext.Response.StatusCode = 404;
                return Task.FromResult(0);
            }, context);
            return next();
        });

        app.Run($Handler);
    }
}
"@

$WebHostBuilder = New-Object Microsoft.AspNetCore.Hosting.WebHostBuilder
$WebHostBuilder.UseKestrel().UseStartup([Startup]::new).Build().Run()
```

19. Groovy (using Spring Boot framework):
```groovy
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@SpringBootApplication
@RestController
class Application {

    @RequestMapping("/your_route")
    void yourRoute() {
        throw new NotFoundException()
    }

    @ExceptionHandler(NotFoundException)
    ResponseEntity<String> handleNotFoundException() {
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body("404 Error - Page not found")
    }
}

SpringApplication.run(Application, args)
```

20. Julia (using HTTP.jl package):
```julia
using HTTP

function handle_request(req::HTTP.Request)
    if req.target == "/your_route"
        response = HTTP.Response(404, "404 Error - Page not found")
    else
        response = HTTP.Response(200, "Hello, World!")
    end
    return response
end

HTTP.serve(handle_request, ("127.0.0.1", 8000))
```

21. R (using plumber package):
```R
# plumber.R

#* Your Route
#* @get /your_route
function() {
    stop(status = 404, message = "404 Error - Page not found")
}

#* 404 Error handling
function(res) {
    res$setHeader("Content-Type", "text/html")
    res$status <- 404
    return("404 Error - Page not found")
}

plumber::plumb("plumber.R")$run(host = "127.0.0.1", port = 8000)
```

22. Elixir (using Phoenix framework):
```elixir
# router.ex

defmodule MyApp.Router do
  use Phoenix.Router

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/api", MyApp do
    pipe_through :api

    get "/your_route", YourController, :your_action
  end

  match _ do
    send_resp(conn, 404, "404 Error - Page not found")
  end
end
```

23. Scala (using Play Framework):
```scala
// routes file

GET     /your_route           controllers.YourController.yourAction

// 404 Error handling
*       /{path:.*}            controllers.Default.notFound(path: String ?= "")

// Default Controller

package controllers

import play.api.mvc._

class Default extends Controller {
  def notFound(path: String) = Action {
    NotFound("404 Error - Page not found")
  }
}
```

24. Clojure (using Luminus framework):
```clojure
;; handler.clj

(ns your-app.handler
  (:require [your-app.controllers.not-found-controller :as not-found]
            [compojure.core :refer [GET ANY routes]]
            [ring.util.response :as resp]))

(defroutes app-routes
  (GET "/your_route" [] (throw (not-found/not-found-exception)))

  (ANY "*" [] (resp/response "404 Error - Page not found")))

(def app
  (-> app-routes
      (handler/site)))

;; controllers/not_found_controller.clj

(ns your-app.controllers.not-found-controller)

(defn not-found-exception []
  {:status 404
   :body "404 Error - Page not found"})
```

25. Rust (using Actix Web framework):
```rust
use actix_web::{App, HttpServer, web, HttpResponse, Result};

async fn your_route() -> Result<&'static str> {
    Err(actix_web::error::ErrorNotFound("404 Error - Page not found"))
}

async fn handle_404() -> Result<HttpResponse> {
    Ok(HttpResponse::NotFound().body("404 Error - Page not found"))
}

#[actix_rt::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new()
            .service(web::resource("/your_route").to(your_route))
            .default_service(web::route().to(handle_404))
    })
    .bind("127.0.0.1:8080")?
    .run()
    .await
}
```

26. Swift (using Kitura framework):
```swift
import Kitura

let router = Router()

router.get("/your_route") { _, response, next in
    response.status(.notFound).send("404 Error - Page not found")
    next()
}

router.all(middleware: StaticFileServer())

Kitura.addHTTPServer(onPort: 8080, with: router)
Kitura.run()
```

27. TypeScript (using Express.js framework):
```typescript
import express from 'express';

const app = express();

app.get('/your_route', (req, res, next) => {
    next({ status: 404, message: '404 Error - Page not found' });
});

app.use((err, req, res, next) => {
    res.status(err.status || 500);
    res.send(err.message || 'Internal Server Error');
});

app.listen(3000, () => {
    console.log('Server running on port 3000');
});
```




404 Is probably the most common error out there and it generally means that you're trying to follow a broken link. Meaning the link URL is directing to a page that does not exist. You can fix it by making sure the URL and the landing page URL matches.
Title: Re: how to solve 404 error ?
Post by: apwebsolutions on 11-08-2016, 00:32:06
You can either put some content up on that URL (Which is showing a 404 error) OR if you don't want that page at all, then you can 301 redirect it to another page. A 404 is essentially a dead link and you don't want too many 404 pages on your website. There are also ways where you can redirect ALL 404's to the home page, but I prefer not to do that.
Title: Re: how to solve 404 error ?
Post by: damponting44 on 11-08-2016, 23:09:39
404 Is likely the most widely recognized blunder out there and it for the most part implies that you're attempting to take after a broken connection. Meaning the connection URL is coordinating to a page that does not exist. You can alter it by ensuring the URL and the point of arrival URL matches.
Title: Re: how to solve 404 error ?
Post by: jainteq on 11-09-2016, 00:01:43
Redirect the 404 error somewhere else. If people are reaching /specials , which is an error page, you can tell your server to redirect people fto /special instead.
Title: Re: how to solve 404 error ?
Post by: NamRay on 11-11-2016, 23:31:40
Sure the 404 is born unwanted for website owners. So how to fix what is 404?

1: When on a website that shows 404 Not Found error appears, the first thing is you need to refresh the webpage or press F5, the site 404 Not Found error, there are many possible causes out. Therefore you should regularly check your site.

2: You should always check your URL to see the 404 Not Found error usually occurs because you entered the wrong URL or URL error

3: You can search directly in the URL of your site are through search sites like google

4: You should regularly delete cookies history

5: Changing DNS server on your computer. It is also seen as one way to help you overcome the 404 Not Found error.

6: Finally, if all of these approaches are not effective then please contact or send mail directly to this web management unit.
Title: Re: how to solve 404 error ?
Post by: RH-Calvin on 11-22-2016, 09:23:39
A 404 error is an HTTP status code that means that the page you were trying to reach on a website couldn't be found on their server. The 404 Not Found error might appear for several reasons even though no real issue exists, so sometimes a simple refresh will often load the page you were looking for. The most common method is to retry the web page by pressing F5, clicking the refresh/reload button, or trying the URL from the address bar again.
Title: Re: how to solve 404 error ?
Post by: pablohunt2812 on 11-22-2016, 21:08:30
A 404 Not Found Error can mean big trouble for an online store and it's customers. Sales and customer satisfaction will drop. It is a lose-lose situation in Ecommerce. Now, because I know you all are winners, we aren't going to lose out with this pesky 404 Page Not Found Error. I'll explain the Error and show you how to fix it for your Online Store. The next time you see this error, you'll have the knowledge needed to fix the error fast and continue to make sales.

How to Recognize the 404 Not Found Error

There are many different ways that you might see this error message on your computer. Be aware that 404 Pages can be entirely customized by the owner of the domain. It can show up any way imaginable but these are some common words that you can look for to know if the Error you see is an HTTP Not Found Error 404

"404 Error"
"404 Not Found"
"The requested URL [URL] was not found on this server."
"HTTP 404 Not Found"
"404 Page Not Found"
The standard HTTP 404 – Not Found Error Page  will be a white screen with simple black text. Here is a screenshot of a basic 404 Page that you might see.
Title: Re: how to solve 404 error ?
Post by: bidaddy on 05-25-2017, 04:08:41
Retry the web page by pressing F5, clicking the refresh/reload button, or trying the URL from the address bar again. ...
Check for errors in the URL. ...
Move up one directory level at a time in the URL until you find something.
Title: Re: how to solve 404 error ?
Post by: Hitesh Patel on 08-10-2017, 02:48:21
a 404 is an HTTP status code it means the page you trying to reach couldn't found in the server. the possibility that file has been deleted or moved. This will helps to pass the link juice.The web site hosting server will typically generate a 404 Not Found web page when users attempt to follow broken link
you can solve from below steps:
(1)You can redirect the web page using 301 redirections if there is any related web page.
(2)Create a new page with the same link with relevant content.
(3)Remove all the Internal links redirect to the broken

Title: Re: how to solve 404 error ?
Post by: SnowflakesSoftware on 08-10-2017, 03:30:30
You can use a 301 permanent redirection to redirect that page to a new location on your website.
Title: Re: how to solve 404 error ?
Post by: mammasseo on 09-04-2017, 05:00:17
Simple Steps to Solve 404 :

Refresh page
Clear browser's cache and cookies
Check the URL
Scan for Malware
Contact the Webmaster
Advanced Troubleshooting
Title: Re: how to solve 404 error ?
Post by: Neel Patel on 09-05-2017, 23:32:50
Quote from: kalmakuran on 11-07-2016, 00:48:13
Hello friends,

Please tell me,how to solve 404 error ?
The HTTP 404 Not Found Error means that the webpage you were trying to reach could not be found on the server. It is a Client-side Error which means that either the page has been removed or moved and the URL was not changed accordingly, or that you typed in the URL incorrectly.
so make sure if the link is broken redirect it or remove it from the website.
Title: Re: how to solve 404 error ?
Post by: Ttacy341 on 09-12-2017, 01:25:45
Quote from: apwebsolutions on 11-08-2016, 00:32:06
You can either put some content up on that URL (Which is showing a 404 error) OR if you don't want that page at all, then you can 301 redirect it to another page. A 404 is essentially a dead link and you don't want too many 404 pages on your website. There are also ways where you can redirect ALL 404's to the home page, but I prefer not to do that.
Great peace of information about 404 errors like Soft 404 errors, 404 (Not found), 410 (Gone). 301 - Permanent redirect. Recently we moved our site TEKSLATE to new design, pages and server and facing some 404 related issues.   I would say this guide will help us in resolving issue.
Thanks for the info.
Title: Re: how to solve 404 error ?
Post by: Emmaballet20 on 09-18-2017, 22:07:21
Thanks Members for your views about "how to solve 404 error" ! I was worried to fix 404 error but finally got good answer to solve it.
Title: Re: how to solve 404 error ?
Post by: Mark123 on 09-19-2017, 23:46:39
You can either create a page at the same url or you can redirect all 404 pages to homepage or some other page
Title: Re: how to solve 404 error ?
Post by: pitterjhon44 on 09-11-2018, 22:07:28
how to solve 404 error ?
Title: Re: how to solve 404 error ?
Post by: hiren popat on 11-27-2018, 01:00:09
404 error means your page URL dead. it could not found in the server. so it could not be showing the page.

you can use 301 redirections to change your URL, which passes all link value to old to new URL.

.refreshes your page: Pressctr+f5 to force on refreshes on the page. The error may appear just because the page couldn't load so try it.

.Check URL: Make sure that you put true URL, it may possible that wrong URL also a reason for 404 error.

.Clear cache and cookies: If you can visit from another device like mobile, Tablet, clearing the cache and cookies will usually solve the problem.

Title: Re: how to solve 404 error ?
Post by: kustifranti on 11-28-2018, 16:50:43
Beyond any doubt the 404 is brought into the world undesirable for site proprietors. So how to settle what is 404?
1: When on a site that indicates 404 Not Found mistake shows up, the primary thing is you have to revive the site page or press F5, the site 404 Not Found blunder, there are numerous conceivable causes out. Accordingly you ought to frequently check your site.
2: You ought to dependably check your URL to see the 404 Not Found blunder more often than not happens on the grounds that you entered the wrong URL or URL mistake
3: You can seek specifically in the URL of your site are through inquiry locales like google
4: You ought to consistently erase treats history
5: Changing DNS server on your PC. It is likewise observed as one approach to enable you to defeat the 404 Not Found blunder.
6: Finally, on the off chance that these methodologies are not successful, it would be ideal if you contact or send letters straightforwardly to this web the executives unit.
Title: Re: how to solve 404 error ?
Post by: Ravina123 on 08-06-2021, 23:43:01
The simplest and easiest way to fix your 404 error code is to redirect the page to another one. You can perform this task using a 301 redirect. What's 301, you may ask? It's a redirect response code that signals a browser that the content has been transferred to another URL.