Nginx map module regex in file

Jagannath Naidu dritto77 at gmail.com
Tue Apr 4 07:31:19 UTC 2017


Hi,

I am trying to redirect some urls to a different document path. My
configuration file is as follows


############ /etc/nginx/conf.d/site.conf ############################
*map_hash_max_size 2048;*
*map_hash_bucket_size 128;*
*map $uri $new {*
*        include list_4;*
*}*
resolver  127.0.0.1;
server {
        listen         81;
        server_name abcexample.com;
        access_log /var/log/nginx/abcexample-access.log main;
        error_log  /var/log/nginx/abcexample-error.log;
        location / {
*                if ($new) {*
*                  rewrite ^ $new redirect;*
*                }*
              proxy_pass http://127.0.0.1:8000;
        }

################# /etc/nginx/list_4 ##############################
/abc/1.html /abc/hello;
/max/1.html /max/;
~^/xyz/(?<abc>.*)$ /xyz/123;
*~^/kkkk/abcdef(?<abc>.*)$ /tttt/bbbbb/jjjj$abc;*

*~^/kaka/(?<abc>.*)$ /tata/$abc;*


Note:
line 1,2 and 3 redirects are working fine.
But line 4 and 5 are not working.


*root at Hell1:~# curl -I abcexample.com/kkkk/abcef111.html
<http://abcexample.com/kkkk/abcef111.html> *
HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Tue, 04 Apr 2017 07:08:47 GMT
Content-Type: text/html
Content-Length: 154
*Location: http://abcdexample.com/tttt/bbbbb/jjjj$abc
<http://abcdexample.com/tttt/bbbbb/jjjj$abc>*
Connection: keep-alive

My Question is:
What changes do I have to do in list_4 file to get results as follows
*Location: http://abcdexample.com/news/bbbbb/jjjj111.html
<http://abcdexample.com/news/bbbbb/jjjj111.html> *


Thanks in advance
- Jagan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20170404/953e2db0/attachment.html>


More information about the nginx mailing list