Rewrite to delete the ID of a url in wordpress

0

I have some addresses indexed with the ID-slug format, and I wanted to create a rule for nginx that would remove the ID

https://misitio.es/12-titulo-del-post-uno
https://misitio.es/45-titulo-del-post-dos
https://misitio.es/56-titulo-del-post-n

pass it to

https://misitio.es/titulo-del-post-uno
https://misitio.es/titulo-del-post-dos
https://misitio.es/titulo-del-post-n

I've tried several regex, and although the regex gives me valid , nginx does not do anything.

rewrite ^([0-9]+)-(.+)$ $2 permanent;

Other

rewrite ^([0-9]+)-(.+)$ $2 last;

Other

rewrite ^/([0-9]+)-(.+)$ /$2 last;

What is I doing wrong?

    
asked by abkrim 09.01.2017 в 08:48
source

1 answer

2

After a few tests I found the one that created the best solution.

location ~ /([0-9]+)-(.+) {
   return   301 https://$server_name/$2;
}
    
answered by 09.01.2017 в 12:36