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 …


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

print “Status: 301 Moved Permanantly\n”;
print “Location:\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.


Leave a Reply

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

You are commenting using your 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: