404 when url includes a period

I have an URL like …/news/10579/13.-august-2007 which results in

404 Not Found

In this case, the last part of the URL is irrelevant for my app and only food for search engines or human readers.

Changing the dot to any of the punctuation marks in “,;:” works fine. I have not experienced this error with any other link and no problem with other engines like apache or nginx or yaws, so this flaw definitely applies to caddy alone.

It does not matter where I place the dot, e.g.

…/news/10579/13-.august-2007
…/news/10579/13-a.ugust-2007
…/news/10579/13-august-2007.
…/news/10579/.13-august-2007
…/news/10579/abcde/13.-august-2007

all deliver the same result

Caddyfile

0.0.0.0

browse

fastcgi / 127.0.0.1:9000 php { 
    env REQUEST_SCHEME {scheme}
}

on startup php-fpm7

log stdout

errors stdout

rewrite {
    regexp .*
    ext /
    to /index.php?{query}
}

Any hint?

Hi @kklepper, welcome to the Caddy community. This one’s a deceptively simple one.

The dot acts as a file extension. With ext /, you’ve excluded any path with a file extension from the rewrite, so the request goes through unaffected, and of course fails when there’s no matching file on disk.


P.S: Drop the regexp .*. You’re just matching all requests - which rewrite does by default - except you’re spinning up a regex matcher, which is a waste of CPU cycles.

Sounds sensible indeed.

I changed my Caddyfile

0.0.0.0

browse

fastcgi / 127.0.0.1:9000 php { 
    env REQUEST_SCHEME {scheme}
}

on startup php-fpm7

log stdout

errors stdout

rewrite {
#    regexp .*
#    ext /
    to /index.php?{query}
}

took down all docker containers, rebuilt the abio caddy container, restarted the docker ensemble – works.

Thank you very much.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.