Forum

Thread tagged as: Problem, Runway

404 problem

I am having trouble getting Runway to show my styled 404 page consistently

See these urls: https://vehicleleasemanagement.co.uk/kokopkpk/ or https://vehicleleasemanagement.co.uk/kokopkpk

Both return just the header and footer

However if I change the url to https://vehicleleasemanagement.co.uk/kokopkpk: (note the colon at the end) or https://vehicleleasemanagement.co.uk/kokopkpk.php

the 404 page shows as I would like.

This is how the Page Options look in Perch https://www.evernote.com/l/Ai8LKYE-Vl5NwYWqcAC1ywG6pbZEB8bAQ0s

How can I correct this?

Neil Duddridge

Neil Duddridge 1 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have anything other than the recommended rewrite rules in your server config?

This is in the .htaccess

AddType x-httpd-php7 .php
Options -Indexes

RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{REQUEST_URI} !^/site_admin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /site_admin/core/runway/start.php [L]
Drew McLellan

Drew McLellan 2638 points
Perch Support

What's the difference between those pages?

I've put debug on:

This url seems to match a route https://vehicleleasemanagement.co.uk/iooioiooi

Matched route: [slug:deal_slug]
Using master page: /templates/pages/deal.php
Page arguments:
Array
(
    [0] => /iooioiooi
    [deal_slug] => iooioiooi
    [1] => iooioiooi
)

This url doesn't https://vehicleleasemanagement.co.uk/iooioiooi.php and the 404 loads fine

It looks like it hits the last route in the order and then loads that page template which in this case is

[slug:deal_slug]  /deal.php 20
Drew McLellan

Drew McLellan 2638 points
Perch Support

There's your answer then. You'll need to handle the missing deal scenario in your page.

Drew McLellan

Drew McLellan 2638 points
Perch Support

In Runway 3 you'll be able to do this...

PerchSystem::use_error_page(404);

Drew McLellan said:

There's your answer then. You'll need to handle the missing deal scenario in your page.

How could this be done?

Drew McLellan

Drew McLellan 2638 points
Perch Support

That's a question to put to your developer rather than me.

I am the 'developer' on this project. It's the reason Perch is used i.e it's ease of use for Frontend designers to work with :)

I'll see what I can figure out.

Neil Duddridge said:

I am the 'developer' on this project. It's the reason Perch is used i.e it's ease of use for Frontend designers to work with :)

I'll see what I can figure out.

Neil, sorry I had to laugh with this response.... lol

When you add the colon to the end of the URL it no longer matches your defined route therefore the 404 error. With a file extension it's seen as a file and with no matching file in the directory you'll get the 404.

I'm having a hard time understanding how the links would be formed wrong if you are creating the links. I'm a visitor is making the error then the 404 is the best result, as only proper links should be honored by the server.

Please explain what your trying to prevent or allow so we can help find a working solution.

Hi Robert,

:)

Basically I am just trying to catch malformed urls which may exist in links from other websites or links from other sites to pages that no longer exist and instead show the visitor a styled 404 page with reason why page wasn't found and what to do next.

On standard Perch sites e.g. not Runway, I build a 404.php then put the following in the .htaccess file

ErrorDocument 404 /404.php

It's how I've always done it but it doesn't work with Runway

I'm thinking that has to be the first line in your htaccess before the perch specific stuff. The only problem this will likely bypass any perch error handling as far as 404's.