I am trying the following steps to my old urls before redirecting them:
1) Rewrite all urls inside a folder by replacing underscores to hyphens
2) Remove the old folder name
3) Try the new urls in multiple url locations to see whichever exists
I've got something like this and couldnt get it to work properly. Is this wrong?
location ^~ /old-folder/ {
#Change Underscores to Hiphens
rewrite ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5;
rewrite ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3;
rewrite ^([^_]*)_(.*)$ $1-$2;
#Remove Folder Name
rewrite ^/old-folder/(.*)$ $1 last;
# Try multiple locations whichever exists
try_files /car-articles/$uri /bike-articles/$uri /index.php?$args;
}
I am absolutely new to rewrites and expressions and I could be way off. Can someone please take a look and point me in the right direction plz...