{"id":788,"date":"2008-10-03T18:10:24","date_gmt":"2008-10-03T10:10:24","guid":{"rendered":"http:\/\/www.janleow.com\/life\/?p=788"},"modified":"2008-10-03T18:10:24","modified_gmt":"2008-10-03T10:10:24","slug":"redirecting-web-pages-using-301-redirect","status":"publish","type":"post","link":"https:\/\/www.janleow.com\/life\/redirecting-web-pages-using-301-redirect.html","title":{"rendered":"Redirecting web pages using 301 redirect"},"content":{"rendered":"<p>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. <!--more--><\/p>\n<p>The htaccess redirection nomenclature is very simple and it goes:<\/p>\n<p><span style=\"background: yellow; text-align: center;\">Redirect 301 \/old\/old.html http:\/\/www.yourdomain.com\/new.html<\/span><\/p>\n<blockquote><p>\nredirect 301 # the instruction that the page has moved<br \/>\n\/old\/old.html  # the original folder path and file name, don&#8217;t use full http:\/\/URL<br \/>\nhttp:\/\/www.yourdomain.com\/new.html # new path and file name with full URL\n<\/p><\/blockquote>\n<p>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.<\/p>\n<blockquote><p>\n# Rewrite current-style URLs of the form &#8216;index.php?q=x&#8217;.<br \/>\nRewriteCond %{REQUEST_FILENAME} !-f<br \/>\nRewriteCond %{REQUEST_FILENAME} !-d<br \/>\nRewriteRule ^(.*)$ index.php?q=$1 [L,QSA]\n<\/p><\/blockquote>\n<p>Since Drupal could use PHP in its content, I could of course use the PHP 301 redirection and it goes:<\/p>\n<blockquote><p>\n &lt;?<br \/>\n header( &#8220;HTTP\/1.1 301 Moved Permanently&#8221; );<br \/>\n header( &#8220;Status: 301 Moved Permanently&#8221; );<br \/>\n header( &#8220;Location: http:\/\/www.new-url.com\/&#8221; );<br \/>\n exit(0); \/\/ This is Optional but suggested, to avoid any accidental output<br \/>\n ? &gt;\n<\/p><\/blockquote>\n<p>The above PHP redirection could only be used for Linux servers, and my web hosting is using it.<\/p>\n<p>Another method of redirection was to use JavaScript (code courtesy of Ryan F):<\/p>\n<blockquote><p>\n&lt;script type=&#8217;text\/javascript&#8217;&gt;<br \/>\nif(window.location.href.indexOf(&#8220;http:\/\/current-url.com&#8221;) &gt; -1)<br \/>\nwindow.location.href = &#8220;http:\/\/www.new-url.com\/&#8221;;<br \/>\n&lt;\/script&gt;\n<\/p><\/blockquote>\n<p>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.<\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.janleow.com\/life\/redirecting-web-pages-using-301-redirect.html\"> <span class=\"screen-reader-text\">Redirecting web pages using 301 redirect<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[12],"tags":[160,162],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1bS5F-cI","jetpack-related-posts":[{"id":812,"url":"https:\/\/www.janleow.com\/life\/finally-removed-my-drupal-installation.html","url_meta":{"origin":788,"position":0},"title":"Finally removed my drupal installation","author":"Jan","date":"15 October 2008","format":false,"excerpt":"Finally it was done. Having used the 301 redirect for those web pages created in Drupal to this Wordpress websites, I could safely uninstall my Drupal installation. Before removing the Drupal installation, I made a quick backup of my .htaccess file. Drupal has a knack of modifying common files that\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3103,"url":"https:\/\/www.janleow.com\/life\/domain-name-with-without-www-prefix.html","url_meta":{"origin":788,"position":1},"title":"To use or not to use WWW before your domain name","author":"Jan","date":"18 August 2011","format":false,"excerpt":"It seems the www. prefix to your domain name is actually a subdomain. When internet first started, and website were being created, www prefix would refer to a website as being a World Wide Web, probably trying to differentiate from the intranet website I suppose. However, due to frequent usage,\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":141,"url":"https:\/\/www.janleow.com\/life\/wordpress-installation-crashed-fix.html","url_meta":{"origin":788,"position":2},"title":"Crashed my WordPress installation but finally got it fixed","author":"Jan","date":"2 July 2008","format":false,"excerpt":"I'm actually quite pleased with this WordPress software for my blog website. It is quite easy to use and has many features. With each upgrade, some new features were added. But my last upgrade caused some problems and took me a whole day to fix it. Ryan asked me whose\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"WordPress URL blog location","src":"https:\/\/i0.wp.com\/www.janleow.com\/imgs\/wordpress_url.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":545,"url":"https:\/\/www.janleow.com\/life\/planning-to-tweak-my-website-again.html","url_meta":{"origin":788,"position":3},"title":"Planning to tweak my website again","author":"Jan","date":"27 September 2008","format":false,"excerpt":"I have been thinking about it awhile. With so many disparate SQL database and sub web site scattered around this personal domain of mine, I thought of cleaning it up a bit. After all, most of the incoming web site traffic is to this blog anyway. This might also meant\u2026","rel":"","context":"In &quot;Personal&quot;","block_context":{"text":"Personal","link":"https:\/\/www.janleow.com\/life\/category\/personal"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":728,"url":"https:\/\/www.janleow.com\/life\/make-drupal-website-cms-content-management-software.html","url_meta":{"origin":788,"position":4},"title":"Making a Drupal Web Site","author":"Jan","date":"22 July 2008","format":false,"excerpt":"Drupal is like a jack of all trades. You could use it for setting a proper website with tier like structure for easy navigation, you could use it to set up a forum, or you just use it to set up a blogging site. It is so versatile that according\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1362,"url":"https:\/\/www.janleow.com\/life\/make-your-own-web-site-the-index-file.html","url_meta":{"origin":788,"position":5},"title":"Make your web site&#8217;s first page &#8211; the index.html file","author":"Jan","date":"1 April 2009","format":false,"excerpt":"The first page you need to make when you make your web site is the index file. This is the web page where a visitor will be greeted when they key in your web site domain in their browser. You may say this is the entry point to start browsing\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/posts\/788"}],"collection":[{"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/comments?post=788"}],"version-history":[{"count":0,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/posts\/788\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/media?parent=788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/categories?post=788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/tags?post=788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}