Multiple redirects

Hi guys,

I’ve a domain xyz.com and I want to

Just to make sure that I’m well understood, here is an example what I’m trying to achieve:
xyz.com => google.com
.xyz Domain Names | Join Generation XYZ => yahoo.com/search/test
.xyz Domain Names | Join Generation XYZ => yahoo.com/search/a

Even after spending almost an hour on it, still can’t figure it out. It’s working for me in Nginx, but can’t figure it out in Caddy.

Any help is appreciated.

What have you tried already? (Show your Caddyfile)

Ha, got it! First rewrite an exact top domain to something random. Then redirect this exact random to the first domain. Then redirect everything else to the second domain.

Probably terrible solution but it works.

    rewrite / {
        r  (^/$)
        to /asdsa
    }

    redir /asdsa https://google.com 301

    redir  https://yahoo.com/search/{uri}
2 Likes

That works! You can also change rewrite / { into rewrite {.

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