Redirect with browse?

Hi All,

  • explain what you are trying to do,
    Very simple - when someone browses to mags/TNA, I want to direct to

This is what I have:

:80 {
tls off
root C:\Users\jungle\Documents\books
redir C:\Users\jungle\Documents\books\mags\TNA\ 301

I’m using Caddy 0.10.4 on Windows 7 64bit.

What am I doing wrong?

browse doesn’t really affect redir. The key point here is the root and how it interacts with request paths vs file paths. redir operates off the request path, not the file path - if you type in your browser, the request path is /foo/bar. If the site root is /var/www, and the request is /foo/bar, Caddy will serve whatever is at the file path /var/www/foo/bar.

Since your site root is C:\Users\jungle\Documents\books, and you want to redirect requests for mags\TNA in that folder, your redir should be:

redir /mags/TNA

Hi @Whitestrake,

That’s still failing. I also can’t redir /mags

I CAN redir /

Hmm. redir needs to match the request path exactly, except for /, which matches everything. So even a slight deviation to /mags/TNA, or requesting something inside that directory, wouldn’t be caught.

rewrite can do catch-alls, though. You can rewrite from the catch-all to an exact path, then redirect that. This might work a little better:

rewrite /mags/TNA {
	to /google
redir /google

Ah, that works great.

Since I was using browse, it was showing the file contents of /mags/TA, which are many pdfs.
Unless I specifically provided a full file name, redir wouldn’t have worked - got it!

Many thanks!

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