Site not working when uploaded to server

Hey folks,

I’m having problems getting my site to work properly on my server. Most things seems to be working ok - the panel is fine, as is the front end. But if I try and click on any of the “Open” links from within the panel, they don’t work - I just get a panel window saying “The view could not be found”.

Here’s what I’ve checked:

  • License is applied (no notice in the panel)
  • Checked all the correct php modules are loaded (output below)
  • .htaccess was uploaded to the server and is complete
  • mod_rewrite is enabled
  • Switched between nginx proxy and plain apache - both failed

I’m not sure where to go from here with regards to troubleshooting this. It seems I hot all the requirements?

~# php -m
[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib

Actually, this is happening locally now too, so something is borked on my Kirby installation.

Try to replace your kirby folder with a fresh one. Happened to me a bunch of times to corrupt involuntarily the kirby folder :innocent:

Thanks for the reply, that didn’t fix it unfortunately.

What do you get in the network tab of dev tools when you click on the link?

Is anything else not working?

Can you remember what changes you did last (or even have a commit history)?

Because I’m only just getting close to deploying, I didn’t put into a Git repo until this morning. :man_facepalming:

I’m continuing to dig into this and it only seems to happen when I click on a child of my blog page. Everything else seems to work ok.

On the console I just get a 500 error:

[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (post-6, line 0)

Do you have any routes in place in your config or in a plugin?

Could you also please post the blueprint for the children of the blog page? Maybe you are redirecting the children and haven’t change the preview link?

I do have a couple routes in place, here they are:

# Custom routes
    'routes' => [

        // Make the non /blog/ URLs work
        [
            'pattern' => '(:all)',
            'action'  => function($uid) {

                # Try fetch the post by looking for a child of the homepage, including drafts
                $page = site()->homePage()->findPageOrDraft($uid);

                # If we have a page and the eventual draft token is present we can return the page
                if ($page && $page->isVerified(get('token')))
                    return site()->visit($page);

                # Else keep going
                $this->next();
            }    
        ],

        // Remove "/blog/" from post URLs
        [
            'pattern' => 'blog/(:any)',
            'action'  => function($uid) {
                go($uid);
            }
        ],

        // Generate sitemap.xml
        [
            'pattern' => 'sitemap.xml',
            'action'  => function() {
                $pages = site()->pages()->index();
      
                // fetch the pages to ignore from the config settings,
                // if nothing is set, we ignore the error page
                $ignore = kirby()->option('sitemap.ignore', ['error']);
      
                $content = snippet('sitemap', compact('pages', 'ignore'), true);
      
                // return response with correct header type
                return new Response($content, 'application/xml');
            }
          ],

          // Redirect sitemap -> sitemap.xml
          [
            'pattern' => 'sitemap',
            'action'  => function() {
              return go('sitemap.xml', 301);
            }
          ],
        
        // Setup the rss feed
        [
            'pattern'   => ['/feed'],
            'action'    => function () {

                $title          = "Kev Quirk";
                $description    = "Latest posts from my blog";
                $posts          = kirby()->collection('posts')->limit(20);
                
                return new Response(snippet('rss', compact('title', 'description', 'posts') , true), 'application/rss+xml');
            }
        ]
    ]

Here’s my article.yml file, which is the blueprint for blog posts:

title: Blog Posts
num: '{{ page.published.toDate("Ymd") }}'
icon: book

status:
  draft:
    label: Draft
    text: The post is still in draft. It's not available on the site and can only be accessed via the panel.
  unlisted:
    label: Unlisted
    text: The post is online, but can only be seen with a direct link.
  listed:
    label: Published
    text: The post is online and listed in the blog.

columns:
  main:
    width: 2/3
    sections:
      fields:
        type: fields
        fields:
          text:
            label: Post Contents
            type: markdown
            size: huge
  sidebar:
    width: 1/3
    sticky: true
    sections:

      meta:
        type: fields
        fields:
          description:
            label: Post Description
            type: text
          published:
            label: Published Date
            type: date
            time: true
            default: now
          tags:
            label: Post Tags
            type: tags
            options:
                - AMA
                - Blogging
                - Books
                - DeGoogling
                - FatBoy
                - FishKeeping
                - Fun
                - HomeLife
                - Meta
                - Notes
                - Opinion
                - Privacy
                - Security
                - StoryTime
                - Technology
                - Watches
                - Web
      
      uploads:
        label: Uploads
        type: files
        limit: 15

Fixed it. I had a custom model setup that was causing the problem.

Changed this:

<?php
class ArticlePage extends Page {
public function url($options = null): string {
return $this->slug();
    }
}

to this:

<?php
class ArticlePage extends Page {
  public function cleanurl($options = null): string {
  return url($this->slug());
      }
  }

Then changed my blog.php template to include <?= $article->cleanurl() ?> instead of <?= $article->url() ?>`.

Thanks to @manuelmoreale for the fix!