Hot answers tagged

6 votes
Accepted

Element API plugin - Return message when no results are found

Currently, Element API is hard coded to throw a 404 exception for single element endpoints, if the element criteria returns no results. There's no way to prevent this exception, add "fallback" ...
Mats Mikkel Rummelhoff's user avatar
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 ...
Sandwich's user avatar
  • 626
5 votes

Unable to manage robots.txt in Craft

You can simply create a 'robots.txt' file in your templates folder and populate it using twig (templates do not need to end in .twig). Not sure what you're trying to control exactly, but something ...
Douglas McDonald's user avatar
5 votes
Accepted

Migrating Craft site to another server --- throws 404 for all pages but homepage

99% chance that it is because the .htaccess file did not come over when you copied the files, as it is a hidden file. Copy that over to your new webroot and those interior pages should properly work.
Patrick Harrington's user avatar
5 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' =&...
TRIM's user avatar
  • 304
4 votes

Changing the default admin path

Have you got your htaccess file working ok? By default the htaccess file is named incorrectly, it should be .htaccess nothtaccess`. You can read about renaming that file in the installation docs. As ...
joep's user avatar
  • 610
4 votes
Accepted

Controller Action 404

When your plugin has a camel cased name you need to make sure you camel case your references to it, such as when you try and visit an action url. I assume this is due to when craft tries to resolve ...
Alec Ritson's user avatar
  • 4,519
4 votes

404 Error showing for Asset Images

Figured it out. I assumed that my assets folder needed 744 just as the install instructions mentioned for the Craft CMS folders. But, I need to change the permissions to the standard 755. Once I did, ...
DevServe's user avatar
  • 303
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 ...
Brandon Kelly's user avatar
4 votes
Accepted

Craft 3 Controller giving 404

Craft 3 action routes are snake-case rather than camelCase thus your route needs to be plugin-handle/controller-handle/function-name instead of pluginHandle/controllerName/functionName Your ...
Robin Schambach's user avatar
4 votes
Accepted

Template not found 404

Craft will serve one of 3 types of 404 errors. When Dev Mode is enabled, you will get something like this, which shows the full stack trace leading up to the NotFoundHttpException: If this looks ...
Brandon Kelly's 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 ...
4midori's user avatar
  • 606
3 votes

Assets (images) return a 404 on the front-end

Just had a similar issue with a colleague. Double check your folder permissions. It might be the case that Craft isn’t allowed to write the transformed files to your assets folder. Something like ...
medoingthings's user avatar
3 votes
Accepted

Unable to manage robots.txt in Craft

It turns out this is an nginx problem. This post describes it: The troubling part of the nginx configuration looks like this location = /robots.txt { access_log off; log_not_found ...
Marion Newlevant's user avatar
3 votes

Lots of 404 Page Errors

Where are the links coming from? A Template? "?p=1504" should not 404, if it's attached to the end of an existing "200" url. Do a crawl with an app called "Screaming Frog" to determine where your ...
joep's user avatar
  • 610
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.
Mike Pringle's user avatar
3 votes
Accepted

Redirecting "if entry is not defined" returns 404 instead

The reason you're getting a 404 is because Craft isn't even hitting your help/_entry.html template. Because there's no entry matching the URI /help/asdf, the template will never render and the request ...
Mats Mikkel Rummelhoff's user avatar
3 votes

Can't access admin panel

I had the same issue on my mac and struggled for hours. Having the right .htaccess file in place was key, but if you are not getting Craft's error messages, that's a sign your .htaccess file is not ...
Topolino's user avatar
3 votes

Security test generated large compiled_templates directory, site outage

I don't have specific answers to your questions, but that's mainly because I feel there are some clarifications and observations that I think might be more helpful. The thread you linked to is ...
Brad Bell's user avatar
  • 67.2k
3 votes

See 404 error cause by some weird URI in index.php

These are very likely bots that are scanning the website for various things (I see it for WordPress logins a ton). Two things you can do: Redirect them. This is what I do for WordPress bots Install ...
andrew.welch's user avatar
  • 11.3k
3 votes

Craft 3 404 and 503 pages in devMode

Just posting this here since I saw an official answer in Github: This changed in Beta 7: UserException reports are now styled like other exceptions when Dev Mode is enabled, with the full ...
Alex Kendrick's user avatar
3 votes

Template not found 404

There's a long discussion of all of this in the Handling Errors Gracefully in Craft CMS article, if it helps.
andrew.welch's user avatar
  • 11.3k
3 votes

Template not found 404

If you've set devMode to false in your local environment and you still can't see your 404 template, go to your own user account in the CMS and uncheck "Show full exception views when Dev Mode is ...
Ryan's user avatar
  • 1,942
3 votes
Accepted

Basic 404 setup not working

If devMode is on, you will always see the above exception page. Turn it off to see your 404 page, or just navigate directly to the template, e.g. http://example.com/404 More here: https://nystudio107....
andrew.welch's user avatar
  • 11.3k
2 votes

favicon.ico throwing 404 TemplateLoader exception

I don't think you can open a .ico file with the browser directly, that's why the request 404s. There's two ways to make it do its thing: simply place it in the web root, e.g. public/favicon.ico use ...
carlcs's user avatar
  • 36.1k
2 votes
Accepted

Installing happylager demo site on own server (not locally)

Thanks @BradBell , your comment made me recheck everything - i just forgot to take out the files from the public folder... now everything looks fine.
moklek's user avatar
  • 41
2 votes

Multi-locale pages 404 on subdirectories

I was running into the same issue, struggling with it and it turns out that the official documentation is a bit misleading (no offense) when it comes to the .htaccess file, because it just mentions to ...
Tobias S.'s user avatar
  • 117
2 votes

Plugin does not exist on 404 page?

If you want to make a new variable available globally, you should do it by registering a new Twig extension, using the addTwigExtension hook. You can use the Twig extension’s getGlobals() method to ...
Brandon Kelly's user avatar
2 votes
Accepted

Plugin does not exist on 404 page?

Ok, this is what I get for trying to be clever (lazy)... I've always begrudged typing in 'craft.myPlugin...' every time I wanted refer to my plugin, so I set a Route Variable in my plugin like so: ...
Mark Notton's user avatar
  • 2,315
2 votes
Accepted

Redirecting certain 404s to a page, handling all others as normal

You could also set up a route for news/{slug} to point to your news template, and have it do the check to see if the entry in segment_2 is valid, and do something based on that. I did something like ...
andrew.welch's user avatar
  • 11.3k

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