You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm making this feature request to consolidate previous requests for dynamic redirects, by which I mean the ability to issue client-side redirects (HTTP 3xx status codes) based on matching the URL to a pattern - presumably a regular expression - not just a fixed string. redir already issues client-side redirects but cannot match a URL pattern, whereas rewrite can match patterns using regular expressions, but doesn't do client-side redirection, so neither of these existing directives are significant.
Those pages identify several situations in which dynamic redirection would be useful:
redirect all URLs with a given file extension, with the new URL depending on the old one
redirect all URLs under a directory tree, with the new URL depending on the old one
stripping or adding terminal slashes
redirecting URLs with single-digit months to have leading zeros
In each case internal rewriting as performed by rewrite is not suitable because it's necessary to signal a change in the page's location to search engines and other visitors.
All of these cases can be addressed with workarounds, but in some cases the workaround is rather impractical, like creating a long list of exact-match redirect rules (1, 2). That wouldn't even work if, say, the destination URL is proxied on to a dynamic backend site where it's not possible to enumerate all valid destinations. (Though in that case one could probably let the backend handle the redirection, but it's not hard to imagine reasons that might be difficult.) So even though it could be argued that dynamic redirection isn't necessary, it would massively simplify the configuration in a wide variety of situation.
Plus, dynamic client-side redirects is something that webmasters typically expect a server to do. Most (all?) other popular web servers include this functionality. I think there are enough cases justifying it that it's worth implementing in Caddy too.
The text was updated successfully, but these errors were encountered:
This adds a new "redirect" directive to the complex rewrite directive. Providing an HTTP response code will force Caddy to issue an HTTP redirect instead of internally rewriting the request.
Fixescaddyserver#1749, caddyserver#726, caddyserver#856
astei
added a commit
to astei/caddy
that referenced
this issue
Jul 6, 2017
This adds a new "redirect" directive to the complex rewrite directive. Providing an HTTP response code will force Caddy to issue an HTTP redirect instead of internally rewriting the request.
Fixescaddyserver#1749, caddyserver#726, caddyserver#856
I'm making this feature request to consolidate previous requests for dynamic redirects, by which I mean the ability to issue client-side redirects (HTTP 3xx status codes) based on matching the URL to a pattern - presumably a regular expression - not just a fixed string.
redir
already issues client-side redirects but cannot match a URL pattern, whereasrewrite
can match patterns using regular expressions, but doesn't do client-side redirection, so neither of these existing directives are significant.Background and justification
This has been previously brought up in
Those pages identify several situations in which dynamic redirection would be useful:
In each case internal rewriting as performed by
rewrite
is not suitable because it's necessary to signal a change in the page's location to search engines and other visitors.All of these cases can be addressed with workarounds, but in some cases the workaround is rather impractical, like creating a long list of exact-match redirect rules (1, 2). That wouldn't even work if, say, the destination URL is proxied on to a dynamic backend site where it's not possible to enumerate all valid destinations. (Though in that case one could probably let the backend handle the redirection, but it's not hard to imagine reasons that might be difficult.) So even though it could be argued that dynamic redirection isn't necessary, it would massively simplify the configuration in a wide variety of situation.
Plus, dynamic client-side redirects is something that webmasters typically expect a server to do. Most (all?) other popular web servers include this functionality. I think there are enough cases justifying it that it's worth implementing in Caddy too.
The text was updated successfully, but these errors were encountered: