• Home
  • Contact
Blue Orange Green Pink Purple

Redirects with .htaccess and Wordpress

Posted in Software, Web. on Sunday, September 10th, 2006 by Dave
Sep 10

Redesigning a static site as a Wordpress based site usually means that the page URLs will change. If any other sites are linking to the old URLs visitors who follow those links will receive a 404 error. If you have a custom 404 this isn’t so bad since the visitor will now be in your site and could presumably use the site navigation to find the page they were looking for. Although most people, including me, can’t be bothered to do this.

The answer is to have a redirect that forwards a visitor to the new Wordpress version of the page. For instance, if a visitor follows /old_page_name.html they will be forwarded to /wordpress_page_name

The easiest solution was staring me in the face when I had to do this today, but I found a few other methods of redirecting on the long way round.

Wordpress Page Template: Redirect to Page
This seemed like the perfect solution - to recreate pages, using this page template, with the same names as the old pages and have them forward to the new pages. It turned out not to work for this purpose though, as when creating permalinks Wordpress removes the full stops from page titles. So a new Wordpress page e.g. page_name.html would become page_namehtml (missing the dot). This page template still seems very useful, though, even if not for this purpose, so i’ve included it here.

HTML Meta Tag Redirect
The second method is based on using a HTML Meta tag to forward one page to another page. In order to use this method pages with the same names as the old pages would have to be created and then the following tag included in the <head> section of the HTML -

<META HTTP-EQUIV=”Refresh” CONTENT=”5; URL=url_of_new_page”>

This method would work, but it’s not really ideal having a ton of html files positioned around your site, for one it makes a mess and two they might be overwritten during a Wordpress upgrade. Read more about this method here.

htaccess
I should have used this all along instead of searching for another method, I have no idea how it slipped my mind.

If you use a custom permalink structure in Wordpress you’ll most likely already know about the htaccess file. This file contains directory-level Apache configurations that can set things like permissions for a specific directory, URL rewriting and among other things… redirection - Which is what we’ll be using it for. Simple redirection is enough for this purpose, all that is required is that the following line be added to the .htaccess file -

RedirectPermanent /some_page.html http://example.com/page_to_redirect_to

So now you can keep your clients happy and have all the old links redirect to their new location. More detailed information on simple and complex redirection using htaccess is available here.

Leave a Reply

區段40

    • No tweets available at the moment.
    • More updates...
  • Categories
    • Advertising
    • Apple
    • Blogging
    • clothing
    • Design
    • Gaming
    • Japan
    • Language
    • Linux
    • Sector40
    • Software
    • Taiwan
    • Tech
    • Uncategorized
    • Visa
    • Web
  • Recent Articles
    • BBC experiment to increase understanding of Globalisation
    • Chunghwa Telecom prepare for Taiwan iPhone release
    • iPhone 2.2 Firmware plus Pwnage Tool Update
    • Megaupload下載問題
    • Configuring Pure-FTP for Passive FTP
    • 在一分鐘內看Mac World的全部
  • Archives
    • December 2008
    • November 2008
    • February 2008
    • January 2008
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • December 2006
    • November 2006
    • October 2006
    • September 2006
  • Search






  • Home
  • Contact

© Copyright 區段40. All rights reserved.
Designed by FTL Wordpress Themes brought to you by Smashing Magazine

Back to Top