Custom error page returns 302 instead of 404
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
-
- Joomla! Apprentice
- Posts: 28
- Joined: Mon Nov 02, 2009 2:53 pm
Custom error page returns 302 instead of 404
I followed this guide to make 404 page based on my current template:
http://docs.joomla.org/Tutorial:Create_ ... Error_Page
Upper part of my current error.php looks like this:
Code:
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
if (($this->error->code) == '404') {
header('Location: index.php?option=com_content&view=article&id=2762');
exit;
}
?>
The only problem I have is that web server returns 302 HTTP status code instead of 404.
I found this fix, but couldn't make it work:
http://docs.joomla.org/Custom_error_pag ... tatus_Code
Code:
<?php
if ($this->error->code == '404') {
header("HTTP/1.0 404 Not Found");
} ?>
Need little advise on how accommodate this code in my error.php
Thanks!
http://docs.joomla.org/Tutorial:Create_ ... Error_Page
Upper part of my current error.php looks like this:
Code:
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
if (($this->error->code) == '404') {
header('Location: index.php?option=com_content&view=article&id=2762');
exit;
}
?>
The only problem I have is that web server returns 302 HTTP status code instead of 404.
I found this fix, but couldn't make it work:
http://docs.joomla.org/Custom_error_pag ... tatus_Code
Code:
<?php
if ($this->error->code == '404') {
header("HTTP/1.0 404 Not Found");
} ?>
Need little advise on how accommodate this code in my error.php
Thanks!
-
- Joomla! Apprentice
- Posts: 28
- Joined: Mon Nov 02, 2009 2:53 pm
- leolam
- Joomla! Master
- Posts: 20652
- Joined: Mon Aug 29, 2005 10:17 am
- Location: Netherlands/ Germany/ S'pore/Bogor/ North America
- Contact:
Re: Custom error page returns 302 instead of 404
Code: Select all
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
if (($this->error->code) == '404') {
header('Location: index.php?option=com_content&view=article&id=159');
exit;
}
?>
Please post a link to your site (not in pmb)?
Leo
Joomla's #1 Professional Services Provider:
#Joomla Professional Support: https://gws-desk.com -
#Joomla Specialized Hosting Solutions: https://gws-host.com -
#Joomla Professional Support: https://gws-desk.com -
#Joomla Specialized Hosting Solutions: https://gws-host.com -
-
- Joomla! Apprentice
- Posts: 28
- Joined: Mon Nov 02, 2009 2:53 pm
Re: Custom error page returns 302 instead of 404
"Visually" custom error page works. It just only returns wrong error code.
See what error code I get from Google webmaster tools when I visit non-existent page:
HTTP/1.1 302 Found
Date: Fri, 29 Oct 2010 10:49:52 GMT
Server: Apache/2.2.3 (CentOS)
How to force it return 404 error code instead?
See what error code I get from Google webmaster tools when I visit non-existent page:
HTTP/1.1 302 Found
Date: Fri, 29 Oct 2010 10:49:52 GMT
Server: Apache/2.2.3 (CentOS)
How to force it return 404 error code instead?
-
- Joomla! Apprentice
- Posts: 28
- Joined: Mon Nov 02, 2009 2:53 pm
Re: Custom error page returns 302 instead of 404
please help
-
- Joomla! Apprentice
- Posts: 7
- Joined: Mon Jun 06, 2011 12:14 am
Re: Custom error page returns 302 instead of 404
I'm having the same issue with my custom 404 page it also returns a 302 in google webmaster tools. anyone find the fix for this?
-
- Joomla! Apprentice
- Posts: 7
- Joined: Mon Jun 06, 2011 12:14 am
Re: Custom error page returns 302 instead of 404
I've exhausted my Google skills..... I can't seem to find the solution.... Anyone have any ideas?
- leolam
- Joomla! Master
- Posts: 20652
- Joined: Mon Aug 29, 2005 10:17 am
- Location: Netherlands/ Germany/ S'pore/Bogor/ North America
- Contact:
Re: Custom error page returns 302 instead of 404
@ Yaksushi:
You have been reported by me for sending me unsolicited support requests; Something I do not appreciate at all! http://forum.joomla.org/viewtopic.php?f=8&t=65 first dot reads:
You have been reported by me for sending me unsolicited support requests; Something I do not appreciate at all! http://forum.joomla.org/viewtopic.php?f=8&t=65 first dot reads:
LeoDO NOT SEND SUPPORT REQUESTS VIA PM, unless expressly invited to do so. Using PM to actively solicit work is not allowed. Post, in accord with the rules in the correct forum. Abuse of the PM system in this way can lead to your membership being removed.
Joomla's #1 Professional Services Provider:
#Joomla Professional Support: https://gws-desk.com -
#Joomla Specialized Hosting Solutions: https://gws-host.com -
#Joomla Professional Support: https://gws-desk.com -
#Joomla Specialized Hosting Solutions: https://gws-host.com -
-
- Joomla! Apprentice
- Posts: 7
- Joined: Mon Jun 06, 2011 12:14 am
Re: Custom error page returns 302 instead of 404
Wow bro, relax..... I sent you a message regarding your post to this topic, nothing else. And it wasn't "Requests" it was a single PM.... Get off your high hoarse and chill out. Your Level 98 Dark Elf Mage will still be there waiting for you.leolam wrote:@ Yaksushi:
You have been reported by me for sending me unsolicited support requests; Something I do not appreciate at all!
Leo
Again I apologize for interrupting your day with my extremely intrusive singular message.
- reggaebkk
- Joomla! Enthusiast
- Posts: 176
- Joined: Mon Jul 14, 2008 1:39 pm
Re: Custom error page returns 302 instead of 404
Hi, I would like to revive this topic that seemed to have been halted on some bad vibe.
I am having more or less the same problem but I am basing my observation on stats rather than logs and scripts:
I was having 130 404 and 25 302 errors per day in my stats, so I made a custom 404 page following the Joomla docs recommendations.
All seems to work fine but now I check my stats and I see that while I don't have 404 errors anymore, I am having nearly 200 302 errors per day.
Since 302 are "Moved temporarily (redirect)", I guess that it's normal, but I have 2 questions:
1/ Is there something I can do to avoid these redirects being seen as an error and a redirect?
2/ Does Google see the trick, does that have an impact on my website image towards Google algorithm?
I am having more or less the same problem but I am basing my observation on stats rather than logs and scripts:
I was having 130 404 and 25 302 errors per day in my stats, so I made a custom 404 page following the Joomla docs recommendations.
All seems to work fine but now I check my stats and I see that while I don't have 404 errors anymore, I am having nearly 200 302 errors per day.
Since 302 are "Moved temporarily (redirect)", I guess that it's normal, but I have 2 questions:
1/ Is there something I can do to avoid these redirects being seen as an error and a redirect?
2/ Does Google see the trick, does that have an impact on my website image towards Google algorithm?
- reggaebkk
- Joomla! Enthusiast
- Posts: 176
- Joined: Mon Jul 14, 2008 1:39 pm
Re: Custom error page returns 302 instead of 404
Just checking: nobody knows the answer? Or did I just say something stupid that doesn't deserved to be replied to? Please enlighten me.
-
- Joomla! Apprentice
- Posts: 13
- Joined: Thu Apr 16, 2015 3:33 pm
Re: Custom error page returns 302 instead of 404
Hello,
I also noticed that the header/location trick:
generates 302 redirects and this is not good for seo!
After searching a lot, I decided to directly edit the error.php page without writing a new custom 404 page article and menu.
Take into account that in the error.php page you cannot include plugins, but you can include scripts and modules, for example:
The above example includes the custom module "name_of_custom_module".
And so, this is valid for menus also.
By coding html and css I was able to 100% replicate the page I wanted for my custom 404 error page.
And, obviously, this returns a real 404 response!
Some info also here:
https://docs.joomla.org/Custom_error_pages
I also noticed that the header/location trick:
Code: Select all
if (($this->error->getCode()) == '404') {
header('Location: /index.php?option=com_content&view=article&id=75');
exit;
}
After searching a lot, I decided to directly edit the error.php page without writing a new custom 404 page article and menu.
Take into account that in the error.php page you cannot include plugins, but you can include scripts and modules, for example:
Code: Select all
<?php $module = JModuleHelper::getModule('custom', 'name_of_custom_module');
echo JModuleHelper::renderModule($module); ?>
And so, this is valid for menus also.
By coding html and css I was able to 100% replicate the page I wanted for my custom 404 error page.
And, obviously, this returns a real 404 response!
Some info also here:
https://docs.joomla.org/Custom_error_pages