thin

Contact information

Feeds

 


  • panoramio
  • Follow LeslieStrom on Twitter
  • LinkedIn profile
  • Internet Movie Database
  • Vimeo
  • adobe reader

301 Redirect from HTML to Wordpress

Written May 2011 -

I have some venerable old content in two online magazines that have a lot of SEO juice. I am moving this content into new WordPress pages and I want to keep the pages' search engine standing intact. Forwarding these pages to the new pages will preserve ten years of web presence. You might be facing one of three scenarios when it comes to forwarding your traffic from an abandoned file to another newer one:

  • PHP to PHP
  • HTML to PHP
  • HTML to WordPress PHP

PHP to PHP forwarding (Not WordPress pages)

There are a couple ways to do this, the easiest being a simple php redirect on the old page. It's a simple line of code that replaces the page content.

  • Make a copy of the original file.
  • Scrape out all the code on the soon-to-be old page
  • paste this in, putting in the URL where you want your page to forward:

<?php
header( 'Location: http://www.yoursite.com/new_page.html' ) ;
?>

  • save with the original file name
  • upload and
  • test

Forwarding HTML Pages to PHP Pages, not in WOrdPress

Follow the directions below, leaving out the WordPress specific stuff.

Forwarding HTML PAGES to WordPress PHP - 301 Redirect and the .htaccess file

PHP commands will not work on an HTML page. The solution for redirecting HTML pages is a 301 redirect for each page, written into a single .htaccess file.

Here's what I figured out with the help of a tech at Bluehost to redirect HTML pages to a new WordPress page/post which has a different URL.

Go into the control panel of your domain. In the root directory you will find a file called .htaccess (it is an odd little text file that's all extension). If you did a "click and drool" installation of Wordpress, there will be a WordPress-friendly .htaccess file there already. If there isn't one, create a simple text file in Dreamweaver or Smultron or Text Edit, save it as .htaccess and upload the blank file to the root of the domain. Now it's ready to add things.

I modify my .htaccess file in Dreamweaver and keep it part of the site so I can easily add new redirected articles and upload quickly.

The first wodge of code has to be the WordPress code that tells WP to use the permalink and not whatever mysterious ID WordPress generates in the bowels of your server when it's asked for a page in the redirect. If it's not there already in your .htaccess file, add it:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Then you follow this with another cluster of code that starts with RewriteEngine On and goes on to list the redirected pages one by one, like this:

RewriteEngine On
Redirect 301 /features/2009/0909venice/0909venice.html http://www.getlostmagazine.com/2009/09/how-to-get-purposely-lost-in-venice/
Redirect 301 /features/2004/0402taxi/taxi.html http://www.getlostmagazine.com/2004/02/taxi/

Note that the original page to be redirected should NOT have the domain name, just starting with the slash (relative URL), and the destination address is written as an absolute URL.

I also learned that if there's more than one space between the original URL and destination URL, it breaks. (Hi, Bill.)

So here's what the final code looks like so far; it works and I'm adding another ninety articles onto it which I hope doesn't slow anything down. A good practise is to add one and then test each one as you go. One botched entry can create a cascading wreck of the subsequent ones.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

RewriteEngine On
Redirect 301 /features/2009/0909venice/0909venice.html http://www.getlostmagazine.com/2009/09/how-to-get-purposely-lost-in-venice/
Redirect 301 /features/2004/0402taxi/taxi.html http://www.getlostmagazine.com/2004/02/taxi/
Redirect 301 /features/2002/0206hat/hat.html http://www.getlostmagazine.com/2002/06/i-want-you-to-have-this-hat/

This simple file is easy to update and will save your hard-won years of traffic and rankings.