2017-10-05 5 views

Répondre

0

Vous devez ajouter ci-dessous

location ~ /[^/]+/[^/]+-[\d+]/ { 
     rewrite ^/([^/]+/[^/]+)-[\d+]/(.*) $1/$2 redirect; 
} 

Dans une url /part1/part2-number/ Les /[^/]+ matchs /part1, /[^/]+ matchs /part2 et -[\d+]/ assortis -number puis votre rewrite pour supprimer le numéro

Résultats du test :

$ curl -I localhost/tarun/lalwani-2/abc 
HTTP/1.1 302 Moved Temporarily 
Server: openresty/1.11.2.2 
Date: Fri, 06 Oct 2017 11:44:23 GMT 
Content-Type: text/html 
Content-Length: 167 
Location: http://localhost/tarun/lalwani/abc 
Connection: keep-alive 

$ curl -I localhost/tarun/lalwani-10/abc 
HTTP/1.1 302 Moved Temporarily 
Server: openresty/1.11.2.2 
Date: Fri, 06 Oct 2017 11:44:27 GMT 
Content-Type: text/html 
Content-Length: 167 
Location: http://localhost/tarun/lalwani/abc 
Connection: keep-alive