Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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


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?

share|improve this question
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 Jan 31 '13 at 11:19
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 Jan 31 '13 at 11:28
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 Jan 31 '13 at 11:35
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 Jan 31 '13 at 11:54

You have to check out the nginx map module


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.

share|improve this answer
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 Mar 8 '13 at 2:04
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 Mar 10 '13 at 13:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .