Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Personalized 404 page ?
#1
Hi,

first, congratulations for your performance, GS is exactly what I was looking for. Really good job. Big Grin

One small issue though : I would like to implement a personalized 404 error landing page. I came across several topics in the forum, but none describes precisely my state of mind.
Let me explain.
As far as I understood from the htaccess that was generated upon installation ( here it is :

Code:
AddDefaultCharset UTF-8
RewriteEngine on

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9-]+)/?$ index.php?id=$1 [L]

) all unknown pages are being matched to their id. That's fine for internal navigation where ids are known and explicitly called. But what about external calls to pages that no longer exist ? The rewrite rule tries to match the file to an id, which doesn't exist, and displays a blank page ... :/

Even worse ( no offence, lol ), if I trust Firebug the header returns a 500 instead of a 404 ! Weird.

I tried to put an errorDocument command in the .htaccess file but with no effect ( it seems to be overridden by the rewriteurl statement )

Could somebody lighten my path there ?
Black holes occur when God divides by zero
Reply
#2
In index.php
find
Code:
$file = "data/pages/". $id .".xml";
    $file_403 = "data/other/403.xml";
    if (! file_exists($file)) {
        if (file_exists($file_403)) {
            $file = $file_403;
            include('admin/inc/403-mailer.php');
        }
    }

replace with
Code:
$file = "data/pages/". $id .".xml";
    $preferred_file = "data/pages/404.xml";    
    $file_403 = "data/other/403.xml";
    if (! file_exists($file)) {
        if (file_exists($preferred_file)) {
            $file = $preferred_file;
            }else{
            $file = $file_403;
            }
            include('admin/inc/403-mailer.php');
        }
basically - lines - 36 through 46 of index.php

what this will do is look for the existence of a page with a slug of 404 and it will serve that page when needed - if that page doesn't exist it defaults to the standard error page

HTH

saul
http://www.twitter.com/sauldraws
Reply
#3
Actually, there already exists a page XML-file for the current error page. You can find it at \data\other\403.xml. Maybe this page should be made editable from the admin.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#4
That would certainly make sense, but having that page as a generic fallback if a custom page doesn't exist also makes sense
Reply




Users browsing this thread: 1 Guest(s)