Closed ohnonot closed 5 years ago
Which URL is shown in your browser when navigating to a non-existing page? Are you redirected to Pico's index page (i.e. the base URL is shown in your URL bar), or are just the contents of index.md
shown instead (i.e. the non-existing URL is shown in your URL bar)?
the non-existing URL is still shown in my URL bar, but I see index.md.
i wish i knew how to troubleshoot this.
We can do this :smiley: Let's see what's going on after Pico has read the page's contents... Create plugins/PicoDebugPlugin.php
with the following content, request a non-existing URL and provide the output:
<?php
class PicoDebugPlugin extends AbstractPicoPlugin
{
public function onContentLoaded()
{
var_dump($_SERVER);
var_dump($this->getPico());
die();
}
}
^ this reveals sensitive information, be careful when using it and make sure to move it completely out of your site root when done!
I think I solved it.
I just found out that the same happens for special pages like /about, /contact etc.
This is what happens:
these pages don't have a template defined.
My index.twig (the default if no template is defined) does not have a simple content section anymore, because it just lists the most recent posts.
Defining a different template in 404.md, contact.md etc. makes them show up properly.
Sorry for the noise; I'd been working on this very long hours and lost the overview.
PS:
I'd still love to get an answer to another question. I know an issue tracker is not exactly the right place for this, but since there's neither forum nor mailing list...
Just as a follow up, I was also having this issue: Pico showing default content instead of a 404 page.
The reason in my case was that the rewrite_url
setting in config.yml was not set (it was set to rewrite_url: ~
)
Changing config.yml
to read:
rewrite_url: true
fixed the issue for me.
I currently have the 1.x version running on my "real" "production" site, but I am testing on pico 2.0.4.
My server software is nginx.
I recently upgraded php-fpm form 5 to 7 - for ALL my sites, not only the testing site. That was a major step, but the real (production) site is working as expected (I mention this because I don't know exactly when the problem started - it might have been there ever since I started using 2.0.4, it might have started after upgrading php-fm, or even later).
The testing site works fine, too, except for pico not displaying error pages. I do have a custom 404.md in my content directory, the same that still works on the production site.
I have played a lot with the nginx server settings - they're slighty different for the production site and 2 testing sites - I switched them around, edited them, and came to the conclusion that pico is responsible here, not nginx.
But I have no other server software to test with, so I cannot be 100% sure.
The pages that are forbidden by nginx configuration show nginx' own 404 or 403 pages, so that works.
Pages that simply do not exist (and are not caught by nginx config rules) always redirect back to the web root (main page, index) instead of showing the custom 404.md.
URL rewriting is enabled both in config.yml and in nginx configuration.
I find no error messages in the logs.
Caching is disabled on the testing sites.
Here's my current nginx config and my config.yml.