Redirecting Question

Reading time: 1 min

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…)

[update]SORTED!!!
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 gordonmclean.co.uk domain:
RedirectMatch 301 /index.php/(.*) http://www.onemanblogs.co.uk/index.php/$1

And now when you click this link (which points at the gordonmclean.co.uk domain) you’ll be properly redirected back to this domain (onemanblogs.co.uk).
[/update]

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 Lifehacker.com 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!!

5 comments

  1. 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.

  2. 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!

  3. 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.

  4. 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…

Comments are closed.