.htaccess 301 redirect regular expression from DotNetNuke to WordPress

I’m moving an old DotNetNuke site to WordPress and though the old site is really crappy architecture and crashes on a regular basis – the site has a fair amount of SEO cred. So, I don’t want to lose anything, but the regular expression is killing me for the .htaccess-based 301 redirect.

Here’s an example of an old domain post:

Read More

http://yoursite.com/tabid/57/listid/4379/Home++Garden/Life+in+Shambles+How+to+Be+Organized.aspx

Here’s how the new one looks:

http://newsite.com/tgesting-new-functionality/

Any help would be greatly appreciated. I’m helping a friend on the site (it’s not mine) and I don’t want to set him back at all and I’m not great with the RegExs.

Thank you!

Related posts

Leave a Reply

1 comment

  1. For redirect

    http://yoursite.com/tabid/57/listid/4379/Home++Garden/Life+in+Shambles+How+to+Be+Organized.aspx
    

    to

    http://newsite.com/life-in-shambles-how-to-be-organized/
    

    You must set in server config at virtual host configuration

    RewriteMap lowercase int:tolower
    

    In your .htaccess file

    RewriteEngine On
    RewriteRule ^([^+]*)+(.*)$ $1-$2 [L]
    
    RewriteCond "%{REQUEST_URI}" "[A-Z]"
    RewriteRule "(.*)" "${lowercase:$1}" [NC]
    RewriteRule /([^/+]+).aspx http://newsite.com/$1/ [R=301,L]
    

    The RewriteMap directive defines a Rewriting Map which can be used inside rule substitution.

    RewriteRule ^([^+]*)+(.*)$ $1-$2 [L] Replace all + by –

    RewriteRule "(.*)" "${lowercase:$1}" [NC] Transform to lowercase

    RewriteRule /([^/+]+).aspx http://newsite.com/$1/ [R=301,L] Do the redirection

    If you need replace consecutives + by a single -, just use RewriteRule ^([^+]*)[+]+(.*)$ $1-$2 [L] instead RewriteRule ^([^+]*)+(.*)$ $1-$2 [L]