• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Redirect users from 404 page after 5 seconds

mkerala

👽 Chevereto Freak
We have to remove certain images from website for variety of reasons. However, there might be significant traffic coming to the image we removed and will be seeing the static 404 page without any ads.

To leverage these traffic hitting 404 pages, a adding a php redirect would drive them to website homepage or any other page.

Redirect users from 404 page after 5 seconds

After line 1 of file /app/themes/Peafowl/views/404.php, add below code

Code:
<?php if(!defined('access') or !access) die('This file cannot be directly accessed.');
header("HTTP/1.1 301 Moved Permanently");
header('Refresh: 5;url=http://yourdomain.com');
?>

Now edit the default messages displayed as follows
Code:
<div class="content-width">
    <div class="page-not-found">
        <h1><?php _se("Image doesn't exist"); ?></h1>
        <p><?php _se('The image you are looking was not found. You will be redirected in 5 seconds.'); ?></p>
        <?php if(CHV\getSetting('website_search')) { ?>

Upload new 404.php file to /app/themes/Peafowl/overrides/views
 
Last edited:
I'm not sure which http status code is sent when you issue a redirect using header() and omitting the response code, but make sure that is 301.

You should do a 301 redirect because Google could penalize you because of sneaky traffic.
 
I'm not sure which http status code is sent when you issue a redirect using header() and omitting the response code, but make sure that is 301.

You should do a 301 redirect because Google could penalize you because of sneaky traffic.

Thanks for the in put. I am very bad at SEO. Added
header( “HTTP/1.1 301 Moved Permanently” );
 
I like this. I changed the 404 message say ing you do not have access. Google Adsense will hit you and ban you for having too many 404s. :(
 
404's are a fact of website life which Google accepts. However, what they most definately don't like is Adsense appearing on actual 404 pages. Basically Adsense should not appear on any "non-content-based" pages.

Adsense policy:

"Publishers are not permitted to place ads on any non-content based pages like thank you, error, login or exit pages."
 
Deutsch:
Vielen Dank für diese Modifikation.
Sehr nett von Dir, uns daran teilhaben zu lassen.

Ich habe die Funktion bei mir eingebaut und sie funktioniert fehlerfrei.
Danke

---------------------------
Translate in english
---------------------------
Thank you for this modification.
Very nice of you, to let us participate.

I have installed the function with me and it works flawlessly.

thanks
 
Does not work in Firefox for me, I tried on 2 different PC's, all other browsers it works perfect, anyone else?
 
FF is a bitch. It's nice and tight and all that, but man, it's not that smart. Been testing FF for a few weeks now. FF shows you how bad you are at configurations wether it's SSL, redirects or whatever. Other browsers fills in the blanks so you don't have to. I'm not sure what's causing the issue here, but surely it's something that FF doesn't like.
 
Deutsch
-------------
Das einzige was in Firefox funktioniert, wäre eine sofortige Weiterleitung.
PHP:
header("HTTP/1.1 301 Moved Permanently");
header("Location:https://yourdomain.yzx/");

Alternativ funktioniert auch eine Javascript Umleitung (im <head> bereich)
JavaScript:
<script>
// Automatische Weiterleitung nach einigen Sekunden
// Angabe in Millisekunden (5000 = 5 Sekunden)
window.setTimeout("location.href='https://yoursite.yzx';", 5000);
</script>

----------------------
Translate in english
----------------------
----------------------
The only thing working in Firefox would be an immediate redirect.
PHP:
header("HTTP/1.1 301 Moved Permanently");
header("Location:https://yourdomain.yzx/");

Alternatively a javascript redirection works (in the <head> area)
JavaScript:
<script>
// Automatic forwarding after a few seconds
// Specification in milliseconds (5000 = 5 seconds)
window.setTimeout("location.href='https://yoursite.yzx';", 5000);
</script>
 
Back
Top