After manually shifting the content from the Drupal database to the WordPress websites, I needed to redirect the traffic from the Drupal pages to the new url. There are several ways of redirecting web pages and each has its pros and cons. According to several web sites, the best way to redirect is to use the htaccess 301 redirect.
The htaccess redirection nomenclature is very simple and it goes:
Redirect 301 /old/old.html http://www.yourdomain.com/new.html
redirect 301 # the instruction that the page has moved
/old/old.html # the original folder path and file name, don’t use full http://URL
http://www.yourdomain.com/new.html # new path and file name with full URL
Since I have not dismantled my Drupal installation, there were some rewrite rules in the htaccess that was messing up the final redirected url. These had to be commented out, but would result in unable to access the Drupal admin panel. In order to access the Drupal admin panel, the rewrite rules will have to be re-enabled. Example of the rules to comment out.
# Rewrite current-style URLs of the form ‘index.php?q=x’.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Since Drupal could use PHP in its content, I could of course use the PHP 301 redirection and it goes:
<?
header( “HTTP/1.1 301 Moved Permanently” );
header( “Status: 301 Moved Permanently” );
header( “Location: http://www.new-url.com/” );
exit(0); // This is Optional but suggested, to avoid any accidental output
? >
The above PHP redirection could only be used for Linux servers, and my web hosting is using it.
Another method of redirection was to use JavaScript (code courtesy of Ryan F):
<script type=’text/javascript’>
if(window.location.href.indexOf(“http://current-url.com”) > -1)
window.location.href = “http://www.new-url.com/”;
</script>
However I did find the JavaScript version slower and in addition it would not provide good standing with the search engine and there is the possibility of losing page rank. Eventually the Drupal software would be uninstalled, so the HTACCESS version would be the best way for redirection.
There are of course more methods of redirection depending on what kind of servers your web site is hosted on, but basically for Linux servers, the above redirection method would suffice.