top | item 41159929

(no title)

biohazard2 | 1 year ago

> So, I decided to create a redirect on Nginx for each old URL, pointing to the new one. It was quite frustrating to write all those redirects…

You can use a regular expression to write a single redirect for all the posts. Something like the following could do the trick:

  location ~ ^/(home|networking|misc|tips)/(\d{4})/(\d{2})/(\d{2})/([a-zA-Z0-9-_]+)\.html {
    return 301 https://giuliomagnifico.blog/post/$2-$3-$4-$5/;
  }

discuss

order

giuliomagnifico|1 year ago

Damn! I didn’t know that Nginx handles regex! Thank you. This would have saved me quite a bit of time… but I already did it.