TYPO3 Core exception: "Id was out of domain" instead of Error 404 - typo3

because of some alterings in the page structure many of our pages changed the pid. It does not matter in SEO terms because of speaking urls but there are a bunch of third party links with wrong pids, e. g.:
https://www.myDomain.de/index.php?id=46&no_cache=1&sword_list[0]=someWord
The page with uid 46 exists but is not the meant one, and it now resides under a different domain. So the result is the following exception:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1518472189:
ID was outside the domain | TYPO3\CMS\Core\Error\Http\PageNotFoundException
thrown in file typo3/sysext/frontend/Classes/Controller/ErrorController.php
in line 80. Requested URL:
https://www.myDomain.de/index.php?id=46&no_cache=1&sword_list[0]=someWord
My question:
Can i tell TYPO3 not to throw an exception but to treat all Outside Domain Events simply as 404 with a redirect to the error page?
thanks!

Should be possible by ading an 404 error handling in Site Management module:
Site Management -> Sites -> Yoursite -> Tab "Error hanling" -> Create new

Showing your 404-page with the correct status code in that case is in my experience unfortunately not too obvious.
The simplest for ?id=... with deleted/moved pages (which because of that do not map to the correct site) is to do redirects to useful pages with EXT:redirect or on the webserver level.
That's an example with EXT:redirect:
If there's nothing comparable in the new content that you could redirect to, you can show your 404-page, e.g. by a passthrough ([PT] with Apache mod_rewrite https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html). You should make sure to send a 404 status in that case. (E.g. through .htaccess, a userFunc on the 404-page, ...).
I hope somebody else has a simpler idea.

Related

How to create cascading page error handlers for a TYPO3 site

Currently it is only possible to add one error handler per HTTP status code in the site configuration, e.g. for 404 or 403. Alternatively you can always write your custom error handler. But this makes it a bit inflexible.
Imagine the following scenario:
default 404 handling would be a specific page, e.g. 12
in a custom error handler I have a cache of URI-to-page mapping. If this gets a hit, the page from that should be displayed. If not, the generic error page 12
which page is displayed should be configurable in the site configuration
or
for 403 I have an error handler which can redirect to a login page
however this may not work in some cases where it should default to standard 403 page
Nice would be if you could configure this for the site so you have something like this:
404
| - custom error handler 1
| - custom error handler 2
| - page error handler
Keeping your extension with the custom error handlers, you could just replace the "page error handler" with a Fluid template for the last step via site configuration.
However, the site module only allows for one error handler per status code (e.g. 404).
I am thinking it might be useful to change this in the TYPO3 core.
But would like to know how others would solve this first.

ember-simple-auth: Error: Assertion Failed: The route index was not found

I am building an app with the use of ember-simple-auth.
So it looks very much like the library its doing is thing.
Here is what happens:
user tries to access /dashboard but is redirected to /
the route / contains the login form
the user logs in with valid credentials
Server responds: /token 200 0.252 ms - 52
But an error message is shown: Error: Assertion Failed: The route index was not found
user navigates to /dashboard and can now see the content, navigate around protected areas, and successfully log out.
My question is, how do I define /dashboard as the route instead of index? So that after successful login you are redirected to /dashboard
You can configure Ember Simple Auth's routeAfterAuthentication in the config, e.g.
ENV['ember-simple-auth'] = {
routeAfterAuthentication: 'dashboard'
}
4 years later...
On Ember Simple Auth Part, you can add routeAfterAuthentication and call it a day, because of ESA default to index.
If we dig deeper, as far as why ESA was and still defaults to the Index route, is that Ember always generates 2 routes for you:
one "" for ApplicationRoute
and "/" for IndexRoute,
You get these 2 routes for free.
I found 3.20 version doc's wording is verbose, so I'm pasting from 1.10 doc, but the idea remains the same
On that perspective, ESA uses IndexRoute as default is a safe bet.

Zend framework 1.2 handling 404

I am having one requirement that I want to manage 404 error differently.
When a system found 404, so before moving it to errorController, it should first check in a table which saves data for special urls and internal project url, if an entry found then it should internally execute that internal url and show the output on the page without changing url.
If no entry found in the table then it should move to error controller as it is.
Please help me on this, I have tried and succeeded using dynamic routing from db, but it is pushing route entries each time page initialize and I want to check this only on 404 to avoid useless load on system.
Thanks

What event to hook to redirect on 404 errors? Symfony 1.4

I am using symfony 1.4.
I need to redirect certain urls when 404 error occurs.
Let's say user is looking for a url http://example.com/oldurl and it doesn't exist I want to check if this url is set for redirect.
If url is set to be redirected I would like to redirect it to that url.
QUESTION: Which event should I hook into to get info about the requested url, that got redirected to 404 error page ?
P.S We only want to check for redirection if page doesn't exist. We do not want to run "the check" for every request, only when page not found!
thanks a lot!
Symfony fire an event each time a page is not found: controller.page_not_found.
You can find it in the documentation: http://www.symfony-project.org/reference/1_4/en/15-Events#chapter_15_sub_controller_page_not_found
Edit:
You can retrieve the url in the method that listen to this event by calling the context. With something like that:
$context = sfContext::hasInstance() ? sfContext::getInstance() : null;
if(null !== $context)
{
$requested_url = $context->getRequest()->getUri();
}
You can give a closer look to the plugin sfErrorNotifierPlugin, it catches exception and 404 error and send an email for a report. Look at how they handle 404 error.
I don't know where to hook exactly inside the execution stack, but I know the general cleaner way through routing. If you are doing routing without still having in code the default routing rule (which you shouldn't by practice since), then it would be as simple as the following in your app routing.yml (at the end):
catch_all:
url: /*
param: { module: yourModule, action: handleNotFound }

How should asp.net custom errors work?

I have implemented custom errors in my asp.net mvc application by following this article. What I have noticed is that if I go to http://www.mysite.com/some-non-existent-controller-and-action I get my 404 error page as expected. However, looking at what happens with firebug, I see that I get a 302 Found response for the non-existent page, which then redirects to my custom error page which then returns with a 404 (and displays the custom error page). Is this right? I don't think the 302 that is first returned is very good especially from an SEO perspective, and that maybe I need to think again about how I have implemented this.
The best guide(i think) for handling 404s can be found in this answer. Basically there are multiple ways in which 404s can happen:
No route exists - matched by the catch all rule.
Matched route but not found a controller - for rules with dynamic controller names - {controller}/{action}/{parameter} rule.
Found route, but didn't find action - handled through HandleUnknownAction override.
Found route and action but couldn't convert parameters - matched by the catch all rule.
The linked answer basically sets up a controller that can be executed from any point in the code without rewriting the URL - which is what you want.
In addition, you should also think about handling unhandled exceptions and bad URLs (like the ones containing unsafe characters like angle brackets). I that particular case you have to rewrite the URL, otherwise you can't render the response at all. These particular requests are kind of tricky, i blogged about that here.
Did you follow the advice down towards the bottom of the page adding a "catch-all" route that maps to your "NotFound" action:
routes.MapRoute("Catch All", "{*path}",
new { controller = "Error", action = "NotFound" });
If you make this the very last route you add, any "unknown" URLs will map directly to your "NotFound" action on the ErrorController and you can just return the "not found" view directly from there, no redirects required.