Rewrite * except wp-login.php to /wp-admin{uri}

1. The problem I’m having:

I want to rewrite every request to /wp-admin{uri} except /wp-login.php.

2. What I tried & What i get

I used this Caddyfile: {
    reverse_proxy :8001

    @wp-login not file wp-login.php
    rewrite @wp-login /wp-admin{uri}

And requested “”.

But I get “404 Not found” from my apache webserver behind the caddy reverse proxy. And in the apache logs shows requests to “/wp-admin/wp-login.php”

3. Caddy version:


4. How I installed and ran Caddy:

a. System environment:

x86_64, Podman with official Caddy docker-image

b. Command:

podman run --detach --network host \
    --volume /home/root/caddy/config/:/config/ \
    --volume /home/root/caddy/data/:/data/ \
    --volume /home/root/caddy/Caddyfile:/etc/caddy/Caddyfile \

5. Links to relevant resources:

Caddy Documentation: matchers

Solved. {
    reverse_proxy :8001

    @wp-login not path /wp-login.php
    rewrite @wp-login /wp-admin{uri}

Used path anstead of file. I did not fully understood the usage of file matcher.

Yep :+1:

The file matcher is for checking if a particular file exists on disk, usually paired with a placeholder as input.

The path matcher is the correct thing to use to have a condition on the request path itself.

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