I'm trying to create a custom 404 page in my admin when something goes wrong and a 404 is thrown.
In my settings.yml file in:
apps/admin/config/settings.yml
I have the following:
all:
.actions:
# 404 module/action
error_404_module: common
error_404_action: error404
I have the module 'common' in my modules folder and I've defined an action called:
executeError404()
and also the template:
error404Success.php
But for some reason, this action never seems to get called as I've tried an exit(); but it still calls the default 404 error message that symfony throws.
Does anyone have any ideas?
Thanks
The custom 404 page doesn't show when in dev mode. If you change your front controller to the production one you should see it if it's configured correctly.
So rather than going to frontend_dev.php got to frontend.php or index.php depending on your setup.
Related
We have a NextJS app hosted on Netlify. We implemented custom error pages using the NextJS _error.js file but when a 404 or 500 error occurs, instead of showing the NextJS error page, we get the Netlify error page.
Is there something in the netlify.toml that we have to disable so that we get our own NextJS error page instead? Or is there another solution
1
To use a custom 404 error page, you'll want to use the custom 404 page at pages/404.js instead of pages/_error.js, since the 404 page will be statically generated. _error.js appears to be mainly for 500 or other server errors. See this tutorial for more information, or the Next.js docs.
To use your new static 404 page with Netlify, you can create a custom 404 redirect with Netlify, which will be shown instead of the default 404 page.
To configure a 404 redirect with the netlify.toml syntax:
[[redirects]]
from = "/*"
to = "/404"
status = 404
I'm using Symfony2.4, and my question is:
- Symfony always tries exception and shows its error page
- But if my web faces 500 error, I want it to show default error page of nginx.
Can anybody help me?
Thanks in advance!
The kernel is catching exception like 500, or 404...
By default, he call TwigBundle:Exception:show controller, that will choose the template to use.
Create this folder.
app/Resources/TwigBundle/views/Exception
And add twig templates with the same name as TwigBundle's templates. They will override the default template.
I am using Symfony 2 framework and I am trying to re-direct my 404 page to another folder on my website. I am wondering how would I do this?
Currently, my 404 error page is located in app/resources/TwigBundle/views/Exception/error404.html.twig. I would like my 404 page to read from src/site/StoreBundle/Resources/views/pages/error404.html.twig.
Note that I only want to re-direct my 404 page. I still want my other errors (500, 503) to remain in app/resources/TwigBundle/views/Exception/error404.html.twig.
I'm not sure why you're wanting to do this so it's difficult to advise but why can't you just put an include in app/resources/TwigBundle/views/Exception/error404.html.twig which pulls in your other template? Be sure to use the correct namespace for your bundle. Something like the below should be fine (edit where appropriate).
{% include 'StoreBundle:pages:error404.html.twig' %}
I've placed a new 404 template file in:
app/Resources/TwigBundle/views/Exception/error404.html.twig
But it's not being shown when 404 is thrown. I've cleared the cache so not sure what else I could do. Any ideas?
Edit: Never mind, apparently it needs to be:
app/Resources/TwigBundle/views/Exception/exception_full.html.twig
I am trying to create a custom error page for 404 errors. I have implemented the Application_Error method in Global.asax.cs. For the most part this works great, but the method isn't getting called for URLs with 4 or more path segments.
The specific URL that I'm having trouble with is:
http://localhost/Area/Controller/Action/ID
If I remove the ID, my custom 404 age loads fine. The problem seems to be having 4 levels in my path (/Area/Controller/Action/ID). Any ideas?
I suspect your routes don't account for a URL with 4 parts. Try adding a catch all route as your last route to test this:
routes.MapRoute("Error404", "{*url}", new {controller = "Error", action = "PageNotFound" } );
Including (some of) your routes in your RouteConfig.cs question might also help.
Set the custom error page for IIS: In IIS rightclick your website/virtual directory --> properties --> custom errors tab --> set the 404 error to your error page.
Your custom errors will only fire for things that fit your route rules. Once all of your route rules fail and it does not find a page at that path it passes the error up to IIS. IIS then uses its 404 rule for object not found so you have to override that and point it back into your project to your custom 404.
Are you getting your IIS error page instead? Try this.
Open IIS, select your website, and choose the option "Error Pages".
Find the 404 status code, right click and go to "Edit Feature Settings".
Now, select "Custom Error pages" and change the "Path Type" to URL "Execute URL"
Finally, put in your URL as a relative value, and now it should redirect to this url on 404 errors.