Friday Freebies: Redirecting 404s


If pages are removed search engines will continue sending traffic to those URL. The value of any links to those pages which pass page rank are lost; One can redirect 404 pages to another location. If only some pages are removed then what one wants to do is redirect only if the page does not exist …

.htaccess

RewriteEngine On
RewriteOptions inherit
RewriteBase /directory/directory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . 404.pl [L]

404.pl

#!/usr/local/bin/perl
print “Status: 301 Moved Permanantly\n”;
print “Location: http://www.domain.com/new/\n\n”;

The 404 script can be more advanced to select page by page or send a different status code if the requested URL is a .jpg.

Advertisements

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

%d bloggers like this: