404 Page Not Found automatic redirect to the homepage? - RESOLVED

Permalink 1 user found helpful
I'm trying to figure out a way to get page_not_found.php to automatically redirect to the homepage. I understand that I copy this from /concrete/single_pages/ to /single_pages but am not sure what code I would insert into this document to make it automatically go to the base_url.

I also tried using the "Page Selector Attribute" and "Page Redirect" add-ons to redirect the Page Not Found system page through the CMS but this doesn't work. I assume this has something to do with how this add-on relates to single pages or something to that affect.

Any thoughts would be much appreciated. Thanks ahead of time.

lackadaize
 
lackadaize replied on at Permalink Reply
lackadaize
should I be using my .htaccess file? Some kind of rewrite condition? I have the following relating to my the rewrite conditions of my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>

I don't really understand quite how this syntax works within the server so I can't rightly modify it to do what I want relating to the 404's. Anyone?
lackadaize replied on at Permalink Best Answer Reply
lackadaize
Using some Wordpress forums I managed to get 404's to redirect using the following code in the 'page_not_found.php' file and it seems to work just fine:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ". 'http://www.mysite.com');
exit();
?>

Now another question. Does anyone know what I would insert to redirect to the 'base_url' instead of hard-coding the site name in this instance? I've tried $base_url <$base_url> and <base_url> as well and they redirected to a page using the actual characters (resulting in 404's) instead of directing to the actual base url.