Here was the challenge. We have a high ranking website in our niche with hundreds of content rich pages and tens of thousands of inbound links. But the FrontPage, HTML based site design was very old and very hard to update and maintain.
I wanted to upgrade to WordPress, which has a ton of really great plugins. And once all the content is imported, it’s relatively easy to redesign on a regular basis. But we couldn’t afford to lose those inbound links, nor did we want people looking for our information to come up empty handed.
So this was a pretty major undertaking. But we’re not alone, so I thought I would outline what we have done in the event it might be able to help others.
Finding an Import Tool and Prepping the HTML files
First, I found a WordPress plugin that would help us import the HTML pages. It’s cleverly called ”Import HTML Pages. One hurdle, however, is that our pages are not “properly formed.” In other words, they lack <div> tag around the main content. Fortunately we had some comment text separating the main content from the header, footer and sidebars, so I knew that with some effort I could do global search and replace of all the files using Replace Text (formerly BK ReplaceEm) to either strip out the header and sidebar info or add a <div> or other tag around the wanted content.
In this case, I ended up using BK Replacem on all of the HTML files to strip out the header and sidebars by stripping out everything between </header> to the <!–start of content–> comment. I also took out the footer between <!–end of content> and </body>. Finally, I replaced <body ….> with <body id=”maintext”> which would help “Import HTML Pages” to treat the import as “well formed.”
But in order to avoid bogging down our server while I did all of this importing and testing, I needed to get WordPress and my new site running on my local computer. Once I had everything up and running, I could then move it out to our HostGator servers (good rates and real live customer support–and we earn a commission if you sign up using this link.)
There is no reason you can’t just import directly to your server, but some experts recommend going this route. On the other hand, if your server can handle the import load, you will save yourself some time and many steps by just doing an import directly to a WordPress install in the folder where you intend to run it.
To run WordPress on a local computer using a Windows operating system, you need to first run a program called XAMPP in order to run the php and mySQL required for WordPress.
- The tutorial I used to install XAAMP and get up and running is Using XAMPP for Local WordPress Theme Development. Another post I found to be helpful is Setup wordpress on local xampp from production server. This later had extra details on changing the MYSQL data base to point in the right place.
- It appears that you can also open the sql file with a text editor to do global search and replace before importing. To empty the data base to import from scratch, select all tables and choose the option to “drop.” I used a text editor on the .sql file to change all occurrences of the “localhost” path and “xampp” path to the correct path.
- To get WordPress installed, it needs to go into subfolder “htdocs”under the Xampps directory. If you put it in the subfolder C:xampps/htdocs/testblog, for example, you can then browse to it by way of http://localhost/testblog/
- With WordPress running, it was easy to get the Import HTML Pages plugin activated. But when I ran the HTML import I had trouble with the path. The plugin appeared to want to import from HTML files from my real website, not from the stripped out files I had stored on my local computer. I tried using the Xampp path in the plugin page in the form of http://afterabortion.org/myblog.org/news but that created a bunch of path errors. The solution was to use the DOS drive path for the directory from which to import files, for example E:\Xammpp\htdocs\myblog.org\news. That worked fine.
- The plugin, Import HTML Pages, will create a redirect file that you can later use to redirect your old links to your new links in WordPress. To make this easier, I suggest leaving the permalink settings to the default (http://myblog/?p=123), until after all the files have been imported. Otherwise the redirect file will have excessively long names.
- All the redirect code needs to go into the .htaccess file. I tried to enable it to work in my Xammp as described in “How to Enable .htaccess in XAMPP.” But I never got it to work. Here’s some more instructions on writing and managing your .htaccess file. And this is yet another highly regarded tutorial Apache Rewrite Cheatsheet. In the end, I just decided I would have to wait to fix the htaccess file once it was on the server and published.
When I later did fix the .htaccess file, I learned that if there is not an index.html file in every subdirectory, the plugin appeared to create a blank page which could cause problems. For example:
“Redirect 301 /PAR/V13/n3 http://afterabortion.org/?page_id=2841″
went no where. Worse, if it appeared in the .htaccess file ahead of the redirect for /PAR/V13/n3/newstudy.html it would block the proper redirect from newstudy.html to the appropriate wordpress page. In the end I had to scour through the .htaccess file and make sure that any redirects to a subdirectory (lacking an html or htm file extension) were either moved to the end of the .htaccess file, or were eliminated. The order of entries in the .htaccess file are very important. If the wrong path is taken early on, then it won’t work properly.
- So now I had all my files in WordPress. To migrate back to the server, see http://wpml.org/2009/03/wordpress-migration-in-5-minutes/
Summary of Migration
While you can just move posts and pages to WordPress using it’s own export and import features, if you have a bunch of plugins and plugin data that you want to move along with the posts, here’s what I did.
- Login to the host server, CPanel. Create new WordPress install using Fantasico. It is best so create the new installation using with same Admin name and password as your old installation. This process should setup the config file for WordPress, which you should be able to leave unchanged.
- Login and update the WordPress version, if necessary.
- Copy all plugins and themes from the old directory to the new directory.
- Backup the old database. Backup the new database.
- From CPanel, open up phpMyAdmin. Select the old database with phpMyAdmin, select all tables, and export.
- Open the exported .sql file with a text editor and change all domain name occurrences from olddomain.com to newdomain.com
- Login into phpMyAdmin and select new database (which is relatively empty). Select and drop (delete) all tables. Import the edited old database. Your new database should be fully populated.
A Half Completed Job
All the pages were now in WordPress, but many of the links were still messed up. A good number of the problems were related to a relative path, like href=”doc1.htm”, which now has to be changed to an absolute path, like href=”http://afterabortion.org/doc1.htm”.
Two useful WordPress Plugins I used here are Search and Replace and Broken Link Checker. The former allowed me to change multiple relative paths in one swipe and the latter helped me find what was not yet fixed.
Other plugins we are using include:
The move was not as smooth as I would have liked, but it had to be done. I hope these notes will make it easier for you.