Apache Redirects

Posted in: Technology

When you move stuff around your site (say because you upgrade from b2 to WordPress), you should remember to redirect people from the old URLs to the new URLs.

Here is the info on how to do redirects on Apache using .htaccess files. (Thanks Scott)

Some people forget to do this until other people remind them to - sorry ’bout that and thanks for the reminder. :)

Popularity: 3% [?]

Posted September 8th, 2003 @ 2:26 PM

5 Replies

  1. Michael adds this Comment:

    Do you redirect b2.php to index.php? How would you do that? I’ve been playing around with it a bit, but have so far not been able to make it work.

    I want to make sure that it passes any parameters to the new link.

    September 9th, 2003 at 5:54 am

  2. Alex adds this Comment:

    I don’t - I use my main site template and just integrated the loops in where I wanted them. Why not just rename b2.php to index.php?

    September 9th, 2003 at 8:02 am

  3. Michael adds this Comment:

    Well I have, but I found that I get a lot of hits to b2.php still! So really I just want to redirect people from b2.php to index.php with the parameters intact.

    September 9th, 2003 at 8:04 am

  4. Alex adds this Comment:

    Ahh, then yes, the redirect would make sense. :)

    There is probably a way to do it in the .htaccess file, but I don’t know it yet so I’ll tell you how to do it in PHP.

    Create a file like this:

    <?php
    ob_start(); // buffer any error message
    @header('Location: index.php'.$_REQUEST["QUERY_STRING"]);
    ob_end_clean();
    ?>

    and replace your b2.php file with it.

    September 9th, 2003 at 8:16 am

  5. geek ramblings adds this Trackback:

    RedirectionI mentioned earlier that I have converted my site to WordPress, and set up link redirection for the old links. There’s some discussion going on over at Alex’s site about this subject as well. I figured I’d put up some notes about what I did.

    September 10th, 2003 at 10:18 am

Add a Comment

Please note: Use of a non-personal web site or blog in the field below and/or comments that are off-topic, personal attacks, or support requests will likely be removed at my discretion.

Note: This post is over 5 years old. You may want to check later in this blog to see if there is new information relevant to your comment.

Cool Sky Tonight » « WordPress Hacks Updated

About This Site

This is the personal web site of Alex King, a web developer in Denver, Colorado USA. More...


Crowd Favorite

Crowd Favorite is my software and web development business.

We build web applications, design and develop custom WordPress themes and plugins, and build custom sites using WordPress as a CMS.


I also have a tumblog that aggregates my online content from other services (Twitter, Flickr, del.icio.us. etc.).

I'm voting for Barack Obama

Ads