verbb / patrol

Easy Maintenance Mode and Smart HTTPS Routing for Craft CMS
MIT License
29 stars 8 forks source link

404 doesn't automatically get HTTPS #21

Open sam327 opened 4 years ago

sam327 commented 4 years ago

I've got a site set up with Patrol, and it forces the HTTPS and www on most pages fine. I've got the sslRoutingBaseUrl, sslRoutingEnabled, and sslRoutingRestrictedUrls set in my general.php config file (just like in the example). It works 99% of the time.

But it doesn't work right for 404s.

Normally, when I go to a page, it automatically changes from http://mysite.com/mypage to https://www.mysite.com/mypage

But when I got to a broken page, http://mysite.com/brokenpageurl, it doesn't redirect.

My 404.twig template lives in the root of the templates directory. So if I go to mysite.com/404, it automatically redirects to https://www.mysite.com/404 - because it's a real page.

But when another page exits to a 404, it doesn't redirect.

I haven't tested 403 or other error pages.

I can reproduce this on a couple unrelated sites. So I'm wondering if the 'exit to 404' bit happens before patrol gets a chance to do its redirect.

selvinortiz commented 4 years ago

@sam327 Your assumption is correct. Patrol is no longer able to initialize in the same way it did in Craft 2 because some of the mechanics for doing that are gone in Craft 3.

I'll have to do some more testing and figure out a workaround.