Redirect from to

Hi all.

Newbie to Caddy here, just kicking the tyres [I currently use Nginx on all my sites]. Could someone show me the recommended Caddy way for redirecting from to I can’t find any examples of this in the docs.


Hi, welcome. :slight_smile: Try adding this to your Caddyfile: {

OK. Cancel that drivel underneath. It’s sorted now.

I was using Opera before. I’ve just tried in Chrome and it works perfectly. I don’t know WTF is going on in Opera’s tiny mind, with all that lunatic recursive redirecting.

Cheers for your help!


1 Like

Maybe Opera was doing some aggressive caching or something…

Must have been something like that. Don’t know if you saw my original post before I deleted it, but navigating to either or, Opera was trying to load:

before giving up with a “too many redirects” error.

leading me to erroneously assume that the redir bit of my Caddy config was at fault.

1 Like

I’ve actually been tearing my hair out over this today.
these redirects are driving me crazy!!!

My site has been running on caddy for months and today started acting weird in a number of browsers; the issue was reported to me by one of the site users first. Out of the blue, I didn’t change anything and now I’ve been fighting it all day.

I do the opposite of you, to & I’m frustrated to the point of not being able to think straight; any help is appreciated.

browsing to works, http doesn’t redirect to https though.

My caddyfile is below, caddy version is 0.9.3 (it was 0.8.* earlier today, upgraded hoping that would fix things) {
} {
root /var/www/wordpress
log /var/log/caddy/access.log
errors /var/log/caddy/error.log

fastcgi / /var/run/php/wordpress.sock php

# Routing for WordPress
rewrite {
    if {path} not_match ^\/wp-admin
    to {path} {path}/ /index.php?{query}


I was only seeing that recursive redirection in Opera. All other browsers were behaving as expected. I “solved” [for tenuous definitions of “solved”] the problem by clearing Opera’s caches.

However, I was in the process of actually tinkering with my Caddyfile at the time, so that kinda makes things breaking to be expected. It seems even more puzzling that you suddenly started seeing this happen, without having touched anything in your setup.

Over to you, Matt!

I’m pretty swamped with research for the next few days; if anyone would like to take a look in the code in the meantime, redirect.go would be the file to start in.

I’m also new to Caddy and am just setting it up and ran into the same issue which I resolved follows:

# Setup vhost for and, {
    root /home/domain/public_html/

You also need to setup a Domain Pointer for I use Digital Ocean and this is a matter of adding the www entry using Networking | Domains. Otherwise when you start caddy you will get the error:

Activating privacy features...2016/12/14 23:51:58 [] failed to get certificate: acme: Error 400 - urn:acme:error:connection - DNS problem: NXDOMAIN looking up A for

You can check that the Domain Pointer is set as follows:

$ dig +short A domain_name

which will display the server’s IP address. You need to do this for and

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