Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Rewrite url with "|" character?

$
0
0
Hi,
Been searching and searching but I can't seem to figure this out.

How do I rewrite a URL containing the pipe (|) character? If I try to do it with just a plain pipe then it seems to treat it like a regex OR and match it anytime I hit a url with the text before the pipe, which is obviously not desired. I've also tried to escape the pipe in a traditional regex way, no dice. If I try with URL encoded (%7C) it doesn't match at all.

rewrite ^/some/path/with|some|parameters$ /some/other/path permanent; # => matches anytime the url starts with /some/path/with
rewrite ^/some/path/with\|some\|parameters$ /some/other/path permanent; # => matches anytime the url starts with /some/path/with
rewrite ^/some/path/with%7Csome%7Cparameters$ /some/other/path permanent; # => never matches

Seems like URLs are un-encoded before processing, so %7C will not work. But how do I properly escape the pipe to make this work?

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>