Redirecting Question

Note: This is a techie question, all those not interested, look away now.

(and no, I’m not doing very well at the whole ‘staying away from the blog to be productive thing…)

That nice man wot writes Hydragenic came through for me (apparently he would ‘not be defeated’, he cracked it second time round).

I’ve added the following line to my .htaccess file on the domain:
RedirectMatch 301 /index.php/(.*)$1

And now when you click this link (which points at the domain) you’ll be properly redirected back to this domain (

I received an email the other day. It was a nice email, the very kind I’d hoped my 404 page would generate.

The problem is a simple one. I moved domains a while ago, so some of the links that still exist point to my old blog URL (which is still live but is no longer a blog).

Following one of those links (from I think) will take you to this URL. Which is currently displaying a 404 error message.

To get to the correct page, all you need to do is edit the URL, replacing “gordonmclean” with “onemanblogs”. Simple.

So why the hell can’t I figure out how to write the appropriate .htaccess commands to get it to do that automatically.

I don’t want to redirect everything, only anything that has “/index.php…..” in the URL. Shouldn’t be THAT hard, right?

Well I’m stuck. So, dearest technical interweb friends, help!!


  1. Mo said:

    If you’re struggling to get .htaccess to cooperate, maybe you could simplify things. Why not use a PHP document as the 404 page, and then put the logic behind the redirection in the PHP. Maybe even a cunning regular expression. Make sense? I’m not so great at expressing myself this early in the day.

    July 11, 2008
  2. Hg said:

    I don’t have an easy way of testing this myself, but if it was me this is what I’d be trying first:

    RewriteCond %{HTTP_HOST} ^(www.)? [NC]
    RewriteRule ^index.php$$1.php [R=301,L]

    July 11, 2008
  3. Hg said:

    Bugger, WordPress has sanitised my input. It’s all correct except that the “1.php” in the second line should have a dollar symbol immediately preceding it (i.e. after the forward-slash).

    Let me know if it works!

    July 11, 2008
  4. izb said:

    The inelegant sledgehammer solution (if all else fails) would be to put some javascript in the 404 page and redirect using that by substituting the domain if it spots a wrong ‘un.

    I know. Eww.

    July 11, 2008
  5. Gordon said:

    Cheers guys, good ideas all.

    And I’m flattered that you think I’d know how to do it in PHP or Javascript! 😉

    Can’t do anything with this until this evening or, more likely, Sunday…

    July 11, 2008

Comments are closed.