Making a custom error page or change the header of error page Making a custom error page or change the header of error page
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Making a custom error page or change the header of error page

Started by kanuharis, December 19, 2011, 06:43:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kanuharis

Hai,
After a hosting crash, I've re uploaded all images and made new albums. Every thing works fine. But right now my Google Webmaster tools showing lots of duplicate content. After hours of checking I have found that old image urls (which is now changed to new album/page url) redirecting to error page, but with 200 found HTTP header instead of 404 not found. So there is 2 urls for same image. As humans can see that there is no such images because the built in error page, still the Google bot can't because found 200 status. I just want to make broken links redirect to a custom error page which have 404 not found header or same original error page, but with 404 not found in the header.
Is this possible?
Thanks in advance

NB. I've tried httacess redirect but no luck.

Αndré

Quote from: kanuharis on December 19, 2011, 06:43:01 PM
I've tried httacess redirect but no luck.
IMO we should fix that issue. But maybe I misunderstood what exactly happened and what you already have done. A link to your gallery will help and also some URLs which returns the 200 header would be helpful.

kanuharis

thanks for quick reply,
Attaching screen shot directly from WMT.
The red round in the pic is outdated (not existing) image url. But was there before hosting crash. After re installed CPG and updated the albums, the order of all albums, pics changed. So if Google search for an old image url, which is not existing or changed to a new location, its still there with 200 found but no pic/album (Actually its an error page that doesn't  understand bots because of 200 found status) On the other hand the same image is there with same title but with another url. So the bot will treat as duplicate content. I think you may understand the situation. Briefly I just want a error page which contains 404 not found in the header for broken links/images instead of coppermine default error page.
thanks in advance
btw my coppermine gallery is http://tinyurl.com/2es4nr

Αndré


kanuharis


Joe Carver

function cpg_die defines what Coppermine returns for a page when it responds to errors.

You can find it in themes/sample/theme.php and copy it into your custom theme.php.

Then you could modify the response to be based on the error.

kanuharis

its seems to be simple, but hard for me :-[
any one please explain..

Αndré

Copy this to your theme.php file:
/******************************************************************************
** Section <<<theme_cpg_die>>> - START
******************************************************************************/
// Function for showing error messages
function theme_cpg_die($msg_code, $msg_text, $msg_string, $css_class = 'cpg_message_info', $error_file, $error_line, $output_buffer, $ob)
{
    global $CONFIG, $lang_cpg_die, $template_cpg_die;

    $params = array(
            '{MESSAGE}' => $msg_text,
            '{FILE_TXT}' => $lang_cpg_die['file'],
            '{FILE}' => $error_file,
            '{LINE_TXT}' => $lang_cpg_die['line'],
            '{LINE}' => $error_line,
            '{OUTPUT_BUFFER}' => $ob,
            '{HEADER_TXT}' => $msg_string,
            '{CSS_CLASS}' => $css_class,
    );

    if (!($CONFIG['debug_mode'] == 1 || ($CONFIG['debug_mode'] == 2 && GALLERY_ADMIN_MODE))) {
        template_extract_block($template_cpg_die, 'file_line');
    }
    template_extract_block($template_cpg_die, 'output_buffer');

    header("HTTP/1.0 404 Not Found");
    pageheader($msg_string);
    echo "<!-- cpg_die -->";
    echo template_eval($template_cpg_die, $params);
    pagefooter();
}
/******************************************************************************
** Section <<<theme_cpg_die>>> - END
******************************************************************************/


This will return every Coppermine error page with the HTTP status 404.

astrasuite

Thanks for this ...

I have private albums which I don't want others to see, I only cpmfetch the images from these private albums for Wordpress.

Google Webmaster was returning Soft 404 errors for private albums and images within, though.  This should solve it.  Probably better than coding for nofollow.