Wednesday 16 September 2015

How to .htaccess helped when migrated Drupal and old URLs became not found

This is indeed very simple, but I thought a lot of people faced this problem, so no harm to write about it.
In the old site I had Pathauto module installed to handle clean (or pretty) URLs patterns across different content types, so a post URL that was post/this-is-an-article became article/this-is-an-article which will result in a lot of ‘page not found’ and dead links in the site which extremely harms SEO, aside from annoying your visitors.
To solve this you can ask .htaccess file to handle the redirects from old URL patterns to new ones. So make sure mod_rewrite is enabled in your Apache settings (if you are using Apache), then inside your .htaccess file add the line below - but make sure to change it to reflect what you have.
RewriteRule ^post/(.*)$ http://worchestra.com/article/$1 [R=301,L]
Basically that will redirect old URLs to new ones, you can apply this to any URL pattern. Hope that helped.

No comments:

Post a Comment