Redirect 403 404 and 500 to home page

You can redirect bad 403, 404 and 500 requests to your home page using .htaccess and php.

In Windows, open notepad and enter the lines:

RewriteEngine On
ErrorDocument 403 /badrequest.php
ErrorDocument 404 /badrequest.php
ErrorDocument 500 /badrequest.php

Next save the text doc to your hard drive as “Save as type: All Files(*.*)” .htaccess.

htaccessbad

Next, upload the .htaccess file to your website’s root directory using filezilla, or another ftp program.

Next create a php file with the following code and save it to the root directory of your website as badrequest.php.

redirectphp

Advertisements

Published by

angelo bonavera

Hi I'm a web developer and I run a web hosting company called 2slick.com.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s