I cannot see anything wrong in your code, and indeed when trying I can replicate this issue. The first route example you posted works perfectly fine with patterns '/favicon'
or '/favicon.jpg'
, but not with '/favicon.ico'
(the /
prefix is optional, as far as I know, but the outcome is the same).
In a similar situation a user once had success with putting the route into a plugin rather than into config.php
, but at least for me that does not solve the problem at hand; I tried with a plugin and get the exact same outcome.
It almost feels like the router chokes on the .ico
being part of the route (as I get a 404 error but no error page, as I do for any other URL that does not exist). Or the server configuration deals with .ico
URLs somehow differently – I do not get any error messages in my server logs, though, and there are no .ico
-specific rules in my server setup files either (Nginx/Linux).
Mysterious!
PS. You could of course bypass this specific problem by adding a rewrite rule to your .htaccess
instead (if you’re on Apache).