Web Hosting

Error 404 Page .htaccess setup

By admin

Two methods that I use:

  1. This just redirects the user to a specified page if the resource they are looking for isn’t found. Add this to your htaccess file to redirect to a file called /404.php:
    ErrorDocument /404.php
  2. This actually rewrites the URL so that the user is not redirected. Instead, Apache shows the same URL but essentially maps it to the /404.php file. You can see this in action here:http://www.rlmseo.com/missingblahblah/.Add this to your htaccess file:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !-d
    RewriteCond %{REQUEST_URI} !-f
    RewriteRule ^(.*)$ /404.php [L]

    The “RewriteBase /” part is optional and depends on your setup.

    This tells Apache to check if the requested resource is a directory, then check if it’s a file, and if both of those are false, map the current URL to /404.php.

Leave a Reply