301 Redirect

Jimmy_Lemon

TPer Emeritus
Messages
12,095
Name
Tom
Edit My Images
Yes
Need some technical help.

I am trying to move my blog from root to /blog directory. Have done the move fine but am trying to make outside links redirect to the new directory.

So I went down the line of a permanent 301 redirect, but I can't make it work. I am editing the .htaccess file and am adding the information I have found on various website, but it just wont work.

I have a feeling I just have the code wrong...this is what I have:

Code:
redirect 301 /index.php?showimage=132 http://www.jimmylemon.co.uk/blog/index.php?showimage=132

Anyone got any ideas?
 
Hi Tom,

Just want to check your base apache config allows directives in .htaccess files? As there is a operative to stop them.
 
Hi Tom,

Just want to check your base apache config allows directives in .htaccess files? As there is a operative to stop them.

Yeah I am sure it does, as a basic index.php redirect to blog/index.php works fine.
 
Your syntax looks ok to me, a few things to try...

1) strip out absolutely everything else from the htaccess file
2) make sure your file is being uploaded and is named correctly, seen problems with hidden file extensions and some ftp clients just skip straight over them
3) try simplifying the redirect, lose the url variables
4) I cant remember whether its case sensitive, so check that too
 
What you want is this (off the top of my head you understand ;))

Code:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^showimage=(.*)$
RewriteRule ^index\.php$ /blog/index\.php\?showimage\=%1 [R=301,L]
 
Thanks everyone and cheers Marcey ;) didn't take you more than a couple of hours tops! :p
 
No matter how many times I read that code of yours marcel (that works a treat) I still don't get it. I hate coding with a passion :)
 
Back
Top