20 votes
Accepted

What's the best way to set up a content-manageable 404 page?

I would create a Single with the URI set to "404", and also set its Template to "404". That entry will automatically get loaded if you go to http://example.com/404, and load your 404.html template, so ...
user avatar
8 votes
Accepted

Controller action works but still gives 404

You're definitely on the right track, just missing out on a couple of key details! The actionUrl function generates a normal, full URL... it's not (by default) an AJAX call. So your browser is ...
user avatar
  • 23.6k
6 votes
Accepted

Craft not loading custom 404 template for errors

Turns out the general.php file had the following line (docs) in it: 'errorTemplatePrefix' => "_errors/" Once I'd created the proper folder and files, all worked as expected. Thanks, @CraftCMS ...
user avatar
  • 616
6 votes
Accepted

Can I define a path to my 404 template?

Yes, use errorTemplatePrefix. 'errorTemplatePrefix' => "pages/",
user avatar
4 votes
Accepted

Contact Form plugin - Error loading 404 Pages

Anywhere you've currently got something that looks like this: {% if message is defined %}{{ errorList(message.getErrors('fromEmail')) }}{% endif %} Try changing that to: {{ message is defined and ...
user avatar
  • 66.5k
4 votes

Craft not loading custom 404 template for errors

It's quite possible that you are in Dev mode. If you switch to false, the 404.html may then be recognized… Look at general.php, then change devMode to false. // Dev environment settings 'dev' =&...
user avatar
  • 284
4 votes
Accepted

Allowing a new locale to fallback on content from a default locale?

One solution (without needing to create a custom plugin) would be to add a lightswitch or checkbox field called useDefaultLocale, and add it to the field layout of any sections that you want to ...
user avatar
4 votes
Accepted

How to show homepage for 404 errors

404 isn’t a valid redirect status code, which is why {% redirect '/' 404 %} isn’t working correctly. It sounds like you want to: first issue a 301 or 302 redirect to the homepage then serve the ...
user avatar
4 votes
Accepted

How to route 404 errors for multi-site Craft?

I pondered this for a while, and then did this, which will direct us to specific entries (not templates, I don't want to create more of those): {# We need a unique 404 for each site - just take us to ...
user avatar
  • 608
3 votes

devMode false, Internal Server Error

Cleared the log files found at /storage/logs/web.log. Tried to view an inner page on the website which threw a Craft "Internal Server Error". Inside the log, I saw "Twig\Error\SyntaxError: Unknown "...
user avatar
  • 61
3 votes
Accepted

404 page title SEOmatic

So it looks like you're using the old syntax for SEOmatic 1.x for Craft 2.x; here's how you do the same thing in SEOmatic for Craft 3: {% do seomatic.meta.seoTitle("Some Title") %} c.f.: https://...
user avatar
3 votes
Accepted

Limit entry pagination to 6 pages?

First, I don’t think your pagination navigation is limiting to just 6 pages like you think it is. The number you pass into paginate.getPrevUrls() and paginate.getNextUrls() will determine how many ...
user avatar
3 votes

Channel URL Format leads to 404s for individual entries

It turned out that when I deleted news/ from the entry URL format, I also deleted it from the entry template path as well because I misunderstood what that field was for (and forgot to revert that ...
user avatar
3 votes

404 problems, staging only

Looking at your screenshots, the host names are different. The cPanel 404 shows mysphotos instead of myphotos. Probably a typo somewhere in your templates.
user avatar
3 votes

6 month old site is suddenly throwing 404s

Since files that begin with a dot are hidden by default in Unix-based systems like OS X, Craft ships with a “htaccess” file rather than “.htaccess”. If you are using Apache and want to use this file, ...
user avatar
3 votes

Can't remove index.php without getting a 404, .htaccess redirect not working, why?

Check and make sure your .htaccess file is in your public HTML folder public/.htaccess! If you do not include your .htaccess file in your public folder, Craft will display your home page properly, ...
user avatar
  • 13.3k
2 votes

What's the best way to set up a content-manageable 404 page?

404 redirect: You could set up your single to use 404-not-found (example) as a uri, and add a redirect: {% redirect '/404-not-found' %} to the /404.html file. That way every 404-page gets ...
user avatar
  • 8,326
2 votes
Accepted

404 problems, staging only

Probably your paths are not set up right; or the SERVER_NAME isn't what you think it is, so it's not matching the paths in your general.php
user avatar
2 votes
Accepted

404 error page not loading

So my issue was very simple to solve once I paid better attention. The 404 was loading perfectly fine the whole time, my problem was that in my 404 file I had it as {% block content %} and not {% ...
user avatar
2 votes

Craft not loading custom 404 template for errors

Make sure you are in production mode in the .env file: ENVIRONMENT=production Make sure you have developer mode disabled in config/general.php file: 'devMode'=>false Make sure you have a 404.twig ...
user avatar
2 votes

Template not found: $PRIMARY_SITE_URL/$PRIMARY_SITE_URL/blog/this-is-my-blog

You have to go to your Admin Dashboard > Settings > Sites > Your site and delete Base URL field, then save it and try to navigate.
user avatar
1 vote

Craft CMS shows disabled entry page

Try adding this to the beginning of your case study entry template: {% if entry is not defined %} {% exit 404 %} {% endif %} Do you have a route set up for your case studies? I've got routing ...
user avatar
  • 482
1 vote
Accepted

404.html template causing twig_error_syntax

The error indicates you're trying to use a Twig filter that doesn't exist in your 404 template at line 4. Maybe you've got a plugin that added it's own filter, but you don't have the plugin installed ...
user avatar
  • 66.5k
1 vote
Accepted

How can I test if a request returns a 404?

That solution is viable. You can just test to see if the entry or the template matches your 404 template/entry. If you routed everything correctly to display a 404 in case of error, you should be fine....
user avatar
  • 36
1 vote

Can I define a path to my 404 template?

Here's more than you ever wanted to know on 404 and error templates in Craft CMS: Handling Errors Gracefully in Craft CMS
user avatar
1 vote

Can't remove index.php without getting a 404, .htaccess redirect not working, why?

Try setting omitScriptNameInUrls to true in your craft/config/general.php file.
user avatar
  • 66.5k
1 vote

What's the best way to set up a content-manageable 404 page?

This is something I discuss in the Handling Errors Gracefully in Craft CMS article, not just for 404s, but for a number of different status codes/errors. The actual templating code then ends up ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible