Advanced search  

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

Pages: [1]   Go Down

Author Topic: Making a custom error page or change the header of error page  (Read 5461 times)

0 Members and 1 Guest are viewing this topic.

kanuharis

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Making a custom error page or change the header of error page
« on: December 19, 2011, 06:43:01 pm »

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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Making a custom error page or change the header of error page
« Reply #1 on: December 20, 2011, 11:32:53 am »

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.
Logged

kanuharis

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Making a custom error page or change the header of error page
« Reply #2 on: December 20, 2011, 04:56:21 pm »

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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Making a custom error page or change the header of error page
« Reply #3 on: December 20, 2011, 07:34:18 pm »

I assume you have to modify the function cpg_die.
Logged

kanuharis

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Making a custom error page or change the header of error page
« Reply #4 on: December 23, 2011, 04:49:27 pm »

dont hate me
Can u please explain
where? what should i do?
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: Making a custom error page or change the header of error page
« Reply #5 on: December 24, 2011, 12:58:01 am »

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

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Making a custom error page or change the header of error page
« Reply #6 on: January 01, 2012, 04:15:39 pm »

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Making a custom error page or change the header of error page
« Reply #7 on: January 04, 2012, 02:35:05 pm »

Copy this to your theme.php file:
Code: [Select]
/******************************************************************************
** 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.
Logged

astrasuite

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: Making a custom error page or change the header of error page
« Reply #8 on: March 23, 2014, 06:07:57 am »

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.
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 20 queries.