1

We have a custom 404 page set up in our EE 4.3.8 to handle non-existing url requests. I can't get it to work though, the home page always comes up instead. I know this may have something to do with how our .htaccess rules are set up but I can't figure out what is breaking this. We have ErrorDocument 404 /site/404 in our htaccess file pointing to the correct template but the 404 page never gets displayed, we also have the static page caching rules from the stash documentation and I'm wondering if they are redirecting our bad urls to our homepage? Here is some relevant code below, the 404 rewriteRule is commented out but ucommenting it and the lines before it still redirect bad urls to our homepage.

## Redirect to Cache File
RewriteRule ^(index.php/*)*(.*)(/*) /ourStaticCacheDirectory/1/$2/index.html [L]

# Prevent direct access to static cache folder
# RewriteCond %{REQUEST_URI} /ourStaticCacheDirectory/
# RewriteCond %{ENV:REDIRECT_STATUS} ^$
# RewriteRule .* /404 [L]

Thanks in advance for any help.

1

There's a setting here: /cp/settings/template turn enable strict urls on and select the proper 404 template just below it

2
  • great! please mark my answer as correct – Jelle Dijkstra Jan 31 '19 at 16:45
  • Unfortunately this solution won't work for me. We have templates that we view directly in our first segment without a template group and this setting will not allow this. So there must be some other way around this? I found an interesting schematic jamessmith.co.uk/images/ExpressionEngine_url_schematic.png which might explain what is happening, but I'm not sure what the options 'is a visible template in default template group' means? Any ideas? – AnyaM Feb 1 '19 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.