We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Problem

404 matching a URL pattern?

Hi,

I'm using the default 404 page in Perch Runway, but it's clashing with a URL pattern

When I mistype a URL like this

mysite.com/fhsjhdghkdhgdg

I would expect the 404 page to be shown, as that page doesn't exist. However, debug shows

Matched route: [slug:project_slug]
Using master page: /templates/pages/projects.php
Page arguments:
Array
(
    [0] => /fhsjhdghkdhgdg
    [project_slug] => fhsjhdghkdhgdg
    [1] => fhsjhdghkdhgdg
)

The 404 page only works if I type in a slug like this:

mysite.com/ftrt:fshfs-;fsdfds

debug then shows

Using master page: /templates/pages/errors/404.php

I can only get the 404 to work if I delete the URL pattern called [slug:project_slug], but I need it to make another part of the website work.

I've had a look in the forum and found a few mentions of PerchSystem::use_error_page(404);, feels like this might be a possible solution, but I'm unsure how to use it.

Any help would be much appreciated.

Summary information

Perch Runway: 3.1.1, PHP: 7.1.12, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Darwin, cgi-fcgi
Installed apps: content (3.1.1), assets (3.1.1), categories (3.1.1), perch_blog (5.6.1), perch_forms (1.11), perch_mailchimp (3.1)
App runtimes: <?php $apps_list = [ 'perch_forms', 'perch_blog', 'perch_mailchimp' ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/stephen/Repositories/project-name/cms/perch
PERCH_CORE: /Users/stephen/Repositories/project-name/cms/perch/core
PERCH_RESFILEPATH: /Users/stephen/Repositories/project-name/cms/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /Users/stephen/Repositories/project-name/cms
HTTP_HOST: mysite.com
Stephen Meehan

Stephen Meehan 4 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Your project route is correctly matching. If you don't have a result when querying for a project with the given slug, you could trigger the 404 at that point.