regex redirection to safe url

1

0

I have several thousand URL's in a CMS formatted like:

/post/en/1539/A+Week+in+Paris+61.html

I'm moving all of the data to wordpress. Where the URL structure will be formated as:

/2011/a-week-in-paris-61/

The post numbers correlate to a date range:

/post/en/1[1-599]/ /2010/

/post/en/1[599-999]/ /2011/

/post/en/2[000-999]/ /2011/

What is the best way to redirect this?

tokyotaco

Posted 2013-01-31T08:49:54.747

Reputation: 11

I am not sure I understand correctly. Do you want to parse various text files containing URLs and change them according to the pattern you described? If so, what operating system are you using? – terdon – 2013-01-31T11:19:44.650

Not text files, the URL's must be changed to remove "+" and remove .html so that it matches wordpress's url encoding. The second thing I want to do is automatically add the date to the destination path depending on the original post # so /post/en/1539/A+Week+in+Paris+61.html becomes /2011/a-week-in-paris-61/ – tokyotaco – 2013-01-31T11:28:41.807

Ok, but where are these URLs? Are they not in HTML files (those are text files)? Are they in a database somewhere? And, again, what operating system are you using? This kind of substitution is quite simple on Unix variants. – terdon – 2013-01-31T11:35:13.957

This is all in a mysql db on a linux box, server is nginx. Not in a text file. I'm reluctant to change this in a database on the old server because I need to be able to easily revert. I can download the top 1000 URL's into a text file from google webmaster tools, but I would have to do it again when errors start coming in for the other missing url's, I've been looking into how I can do this as a redirect/rewrite using regex. – tokyotaco – 2013-01-31T11:54:17.400

Answers

0

You have to check out the nginx map module

update:

Now since some think I have to write a novel concerning this, I'll have to elaborate with some meaningless explanation that if you follow that link, you will see that what you are trying to do (rewrite a whole lot of urls) is perfectly implementable using the nginx map module. I realize this last paragraph is utterly useless since the original complainer didn't even bothered to verify that page which has all the information you need to successfully reach your goal.

Glenn Plas

Posted 2013-01-31T08:49:54.747

Reputation: 121

Welcome to SuperUser.  Answers that consist of only a link are frowned upon.  Please edit your answer and include a summary of the linked material. – Scott – 2013-03-08T02:04:48.863

It's to the point though, I'm not a newbee on stackexchange, so research that first before trying to act like I am. That page is exactly what he is looking for,I do not have to clutter this answer with meaningless stuff. It's EXACTLY what he needs. Correct short answers are NEVER frowned upon. – Glenn Plas – 2013-03-10T13:35:17.000