Variable for the suffix of $request_uri that didn't match the location block prefix
Posted
by
hsivonen
on Server Fault
See other posts from Server Fault
or by hsivonen
Published on 2013-10-20T10:40:45Z
Indexed on
2013/10/20
15:56 UTC
Read the original article
Hit count: 167
nginx
Suppose I want to move an /images/
directory to an images
host so that what was before http://example.org/images/foo.png
becomes http://images.example.org/foo.png
.
If I do: location /images/ { return 301 http://images.example.org$request_uri; }
, the result is a redirect to http://images.example.org/images/foo.png
which isn't what I want.
An older question has an answer that suggests using a regexp location
, but that seems like an overkill.
Is there really no way to refer to $request_uri
with the location
prefix chopped off without using regular expressions? Seems like an obvious feature to have.
© Server Fault or respective owner