Hi, I need to enable rewrite rules on my WordPress site with Caddy 2 server.
When I was on NGINX, I was doing the following:
location / {
try_files $uri $uri/ /index.php$args;
}
In the same way when I just keep:
try_files {path} {path}/ /index.php?{query}
on Caddyfile, everything is working fine except I am getting error too many redirects on:
https://mysite.com/wp-admin/
path. So, it is necessary that I must exclude /wp-admin/ path from rewrite since rewrite for that path is not necessary for me.
That were the main problem appeared I tried many ways but I am unable to exclude /wp-admin/ path from try_files directive. I checked documentation many times but I donβt see a way to exclude a path.
I tried to validate with many ways but failed such as the following: So please help me!
@try_files {
file
not path /wp-admin/* {
try_files {path} {path}/ /index.php?{query}
}
}
rewrite @try_files {http.matchers.file.relative}
@wp-admin {
not path /wp-admin/*
}
rewrite @wp-admin {path} {path}/ /index.php?{query}
@wp-admin {
not path / /wp-admin/*
}
rewrite @wp-admin /index.php?{query}
@wp-admin {
not path /wp-admin/*
}
rewrite @wp-admin {path} {path}/ /index.php?{query}
@wp-admin {
not path /wp-admin/*
}
try_files @wp-admin {path} {path}/ /index.php?{query}
@try_files {
not path /wp-admin/*
try_files {path} {path}/ /index.php?{query}
}
rewrite @try_files {http.matchers.file.relative}