By freakdaddy on
Is there a way I can send all 404/403 errors to my main page? I tried setting "Default 404 (not found) page:" to index.php but that strangely shows a page with a nothing but a number 2 on it. http://www.freakyacres.com is my website. http://www.freakyacres.com/notarealpage doesn't exist.
Comments
Where it asks you to put a
Where it asks you to put a link for 403 and 404, just put "node", it should redirect to your "homepage" since yoursite.com/node is your homepage.
Works great! Thank you!!!
Works great! Thank you!!!
Actually it works sort of
Actually it works sort of good. http://www.freakyacres.com/?q=node/19 (which doesn't exist anymore) is not the same as http://www.freakyacres.com
Any idea on how to get around that?
=-=
not understanding what you mean ? if the node doesn't exist you are being redirected back to your front page, based on "node" being in the 403 redirect.
I'm not understand what you mean by, "is not the same as" ?
Do you mean "not redirecting the same as" ?
If you don't mind click the
If you don't mind click the two links I supplied and note the difference. When "node" redirects it shows my front page but all of the left block is missing.
Did you find the solution?
I am having the same problem as you explained. There is no problem to have the missing page redirected to my home page, but all sidebars are missing. For instance, if we tried to access http://thetwins.info/joining-the-crowd.html (which I have moved), all sidebars are missing. But if we direcly accessed http://thetwins.info/home.html, all sidebars are there.
So I am wondering if you found the solution for your problem. If so, could you please let us know?
Not really sure, but one
Not really sure, but one assumes you may not be able to set block display for pages that do not exist?
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
A bit confused here
I thought that when we set the 404 page in admin/settings/error-reporting, that page will be rendered after Drupal sends the "HTTP/1.1 404" in the html header. At least that is what I saw in my Lighttpd log. As I set the page to "home.html" which is definitely exists, that page should be rendered together with all the sidebars. Is my understanding wrong?
Yea, for sure, I checked
Yea, for sure, I checked your header response and its definitely 404, but the URL does not change and block visibility settings can be based on the path, so that's what made me think along those lines. I am certainly not 100% on this thinking, just a thought.
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Jeff, you are right and the solution is quite simple
I pointed the 403 and 404 pages to "home.html" but only the handling of 403 status is working properly. When I compared the functions drupal_access_denied() and drupal_not_found() in includes/common.inc, I saw that the function drupal_not_found() omits the block. It says like below:
So after changing the line to
The block is being displayed. So the solution is quite simple.
FYI. I am using Drupal 6.4 in case somebody is wondering.
Have a look here
Have a look here http://api.drupal.org/api/function/drupal_not_found/5. The comment right before the
returnprint in the code says: "// To conserve CPU and bandwidth, omit the blocks". drupal_not_found (the function that executes on a 404) strips blocks on purpose by setting the last parameter of it's theme_page call to FALSE.Thanks Brian
I found it about half an hour ago before I posted my previous comment. Thanks a lot anyway, Brian.
Np. However I would caution
Np. However I would caution against modifying core files. The biggest reason is that when you upgrade you will have to re-apply the changes again, every time you upgrade. This can get really, really annoying trust me I learned the hard way.
I believe you Brian - a bit off topic
I started to use Drupal since version 6.1 back in March this year, so I am very new to this. If you would like to read the story, it is here.
I totally agree with you that we should not make any modification especially to the core modules. I also think that it is better to submit a change request including the patch if we could make it. But the process usually takes a long time. And if we would be lucky the changes will be included in the next version. So sometimes we don't have any choice rather than to apply the changes ourselves. Based on my experience using Open Source Software, I usually choose the last one as especially it makes me mentally more healthy :)
For instance, I could not find a good way to have the title of the blog from "admin's blog" and everything related to that, changed into "Our news room". So I had to modify the blog module to have it changed. As you said, I have to apply the changes every time I upgrade Drupal. I have done that 4 times up to now as I am now using Drupal 6.4. Even I do that changes by hand, I seem to find an easier way to have all changes applied to the new version. The process seems to be complicated though.
What I do before switching to the new version, firstly I take the differences between the version I have (with the modification) and the current Drupal version, as I am sure I forget all changes that I have made. I log it into a file using command diff -urN <old version> <mod version> > current_differences.txt, so I know the changes that I have made. Then I take the differences between the "mod version" and the "new version" using the command diff -urN <mod version> <new version> > new_differences.txt, which tells me where to re-apply the changes. Base on that information, I edit each of the files in the new version to re-apply the changes. FYI, I have also made changes on the other modules especially the Brilliant Gallery (lots of them) and Lightbox2. And I usually complete all changes in less than 15 minutes. Maybe it is because I don't have massive lines of changes :) So I am not sure if it is worth the effort to automate the process.
Before somebody ask. I always have 2 versions of Drupal in my webserver. The live version and the development version. I apply the changes to the development version. So the switch to the new Drupal version can be done in a split second (sort of).
I would look for a module
I would look for a module that can help you do this without the core modification. I found this one, there may be others:
http://drupal.org/project/customerror
To have blocks after
To have blocks after redirecting to home page install this module http://drupal.org/project/blocks404
My solution:
I decided to implement a custom menu and redirect from there:
Can you try with .htaccess
Can you try with .htaccess entry
Using hook_preprocess_page
It will redirect all 404 pages to home page
function hook_preprocess_page(&$variables) {
global $base_url;
$status = drupal_get_http_header("status");
if ($status == "404 Not Found") {
header("Location: " . $base_url);
drupal_exit();
}
}