Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We recently did a migration from a "custom CMS" (coded from scratch) to our current technology news/reviews site, MuyComputerPRO, which we installed in WordPress a couple of weeks ago.

The migration process has been long and complex, and we are now facing the colateral damage: old-duplicated URLs (more on this later) don't work, giving a 404 error page.

The old CMS generated URLs dinamically, and those permalinks weren't permanent. The last part of the link was a alphanumeric code that also could change from article to article, so the same webpage could have several different URLs. I know. I arrived here late.

We have managed to get the "last" permalink that was assigned to each article, and we have setup this permalink as the one used on WordPress after a database migration. This way, each of the old articles have at least a good URL that Google already knows about.

The problem is, the rest of duplicated URLs are lost, and Google Webmaster Tools has noticed this and gives a report with thousands of 404 errors on those duplicated links (our database has over 12.000 articles).

I think the only solution to this is to create 301 redirections. Our web server is Nginx, and althoug I've investigated how to accomplish this in Nginx, the current solutions don't fit well in our model.

Examples of a bad/duplicated URL:

*www-muycomputerpro-com/Actualidad/Protagonistas/Nueva-estructura-de-SAP/_wE9ERk2XxDBuybOru8KSMQ5WAzIEAjFyaz70NzGocxqh0Aam7PBrCxu9Dl2Y0RcK*

And the good one is

*www-muycomputerpro-com/Actualidad/Protagonistas/Nueva-estructura-de-SAP/_wE9ERk2XxDBuybOru8KSMW2WfV_v9dGn6boQF-rm0B25JbFBs4Bqve7uMmhtXVNn*

As you can see, the final code is the one that must be changed, and I fear there's no "general" 301 redirection rule for that.

Will we have to specify ONE BY ONE the bad and good URLs? We could that (there's a Wordpress plugin, called Redirection, that let's you do this in a simple way), but it would be a little hell :(

Please, help!!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

My suggestion is to write a file with redirection rules for nginx and include it on the server config. You can also use a script to automatically generate the rules.

rewrite  /Actualidad/Protagonistas/Nueva-estructura-de-SAP/_wE9ERk2XxDBuybOru8KSMQ5WAzIEAjFyaz70NzGocxqh0Aam7PBrCxu9Dl2Y0RcK /Protagonistas/Nueva-estructura-de-SAP/_wE9ERk2XxDBuybOru8KSMW2WfV_v9dGn6boQF-rm0B25JbFBs4Bqve7uMmhtXVNn permanent

Create a file with lines like these and use include to add them to the config.

But yes, you're right, unless this code at the end of the URL can be generated by a regex or something like that, there's no way to make it automatic.

share|improve this answer
    
That is precisely what we can do with the Redirect plugin, but from WordPress itself, and not inside Nginx conf. And that's what I'd like to avoid. We'll have to search each equivalence (old->new) and perform the redirection one by one :( Another possibility: to edit old permalinks (from the old CMS), truncate them and leave them without the last part (the large code after the last slash) and from there, create a redirect rule, this time with a regular expression, something like: www-muycomputerpro-com/(.*)/(.*)/(.*)/(.*) www-muycomputerpro-com/$1/$2/$3 –  javipas Dec 6 '10 at 19:39
1  
You can try this rule rewrite ^/(.*)/(.*)/(.*)/(.*)$ http://www.muycomputerpro.com/$1/$2/$3 permanent –  coredump Dec 10 '10 at 20:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.