{"action":"created","issue":{"url":"https://api.github.com/repos/mholt/caddy/issues/1107","repository_url":"https://api.github.com/repos/mholt/caddy","labels_url":"https://api.github.com/repos/mholt/caddy/issues/1107/labels{/name}","comments_url":"https://api.github.com/repos/mholt/caddy/issues/1107/comments","events_url":"https://api.github.com/repos/mholt/caddy/issues/1107/events","html_url":"https://github.com/mholt/caddy/issues/1107","id":176682558,"number":1107,"title":"Execute redirections before rewrites","user":{"login":"hlidotbe","id":193949,"avatar_url":"https://avatars.githubusercontent.com/u/193949?v=3","gravatar_id":"","url":"https://api.github.com/users/hlidotbe","html_url":"https://github.com/hlidotbe","followers_url":"https://api.github.com/users/hlidotbe/followers","following_url":"https://api.github.com/users/hlidotbe/following{/other_user}","gists_url":"https://api.github.com/users/hlidotbe/gists{/gist_id}","starred_url":"https://api.github.com/users/hlidotbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hlidotbe/subscriptions","organizations_url":"https://api.github.com/users/hlidotbe/orgs","repos_url":"https://api.github.com/users/hlidotbe/repos","events_url":"https://api.github.com/users/hlidotbe/events{/privacy}","received_events_url":"https://api.github.com/users/hlidotbe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-13T16:05:16Z","updated_at":"2016-09-23T16:23:44Z","closed_at":null,"body":"### 1. What version of Caddy are you running (`caddy -version`)?\r\n\r\nCaddy 0.9.1 (+e8e5595 Thu Sep 01 09:31:58 UTC 2016)\r\n\r\n### 2. What are you trying to do?\r\n\r\nRedirect old uri to their new location AND rewrite missing paths to default handler\r\n\r\n### 3. What is your entire Caddyfile?\r\n```text\r\n:8080\r\ngzip\r\nlog stdout\r\nerrors stderr\r\nroot /var/www\r\nfastcgi / /var/run/php-fpm.sock php\r\n\r\nrealip {\r\n  from 172.17.0.0/16\r\n}\r\n\r\nredir 307 {\r\n# Lots of from/to (about 200)\r\n}\r\n\r\nrewrite {\r\n  r ^/(.*)$\r\n  to {path} {path}/ /index.php?q={1}&{query}\r\n}\r\n```\r\n\r\n### 4. How did you run Caddy (give the full command and describe the execution environment)?\r\nCaddy is running in a docker container under runit supervision alongside php-fpm in an alpine 3.4 image.\r\n\r\n```sh\r\n#!/bin/sh\r\nexport CADDYPATH=/tmp\r\nexec chpst -u caddy /sbin/caddy -conf=/etc/caddy.conf\r\n```\r\n\r\n### 5. What did you expect to see?\r\n\r\nI expect/want redirections to be run BEFORE rewrites. So if a redirect matches, it should be executed and stop further processing\r\n\r\n### 6. What did you see instead (give full error messages and/or log)?\r\n\r\nNot an error per-se but the final url is rewritten to `/index.php?q={1}&{query}` and never matches the redir paths\r\n\r\n### 7. How can someone who is starting from scratch reproduce this behavior as minimally as possible?\r\n\r\n```\r\n:9000\r\n\r\nroot .\r\nlog stdout\r\nerrors stderr\r\n\r\nredir 302 {\r\n  /something /something-else\r\n}\r\n\r\nrewrite {\r\n  to {path} /foo?q={path}\r\n}\r\n```\r\n\r\nIf I comment the rewrite block I'm redirected to /something-else but otherwise I see in the logs Caddy trying to fetch /foo?q=/something"},"comment":{"url":"https://api.github.com/repos/mholt/caddy/issues/comments/249237851","html_url":"https://github.com/mholt/caddy/issues/1107#issuecomment-249237851","issue_url":"https://api.github.com/repos/mholt/caddy/issues/1107","id":249237851,"user":{"login":"elcore","id":15967995,"avatar_url":"https://avatars.githubusercontent.com/u/15967995?v=3","gravatar_id":"","url":"https://api.github.com/users/elcore","html_url":"https://github.com/elcore","followers_url":"https://api.github.com/users/elcore/followers","following_url":"https://api.github.com/users/elcore/following{/other_user}","gists_url":"https://api.github.com/users/elcore/gists{/gist_id}","starred_url":"https://api.github.com/users/elcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elcore/subscriptions","organizations_url":"https://api.github.com/users/elcore/orgs","repos_url":"https://api.github.com/users/elcore/repos","events_url":"https://api.github.com/users/elcore/events{/privacy}","received_events_url":"https://api.github.com/users/elcore/received_events","type":"User","site_admin":false},"created_at":"2016-09-23T16:23:44Z","updated_at":"2016-09-23T16:23:44Z","body":"Hello @hlidotbe,\r\n\r\nfeel free to create a PR 😄 (my opinion)\r\n\r\n@mholt what do you think?"}}
{"actor":{"display_login":"elcore"}}