Forum Moderators: phranque

Message Too Old, No Replies

301 redirect sub folder trouble .htaccess

         

misterm2008

7:11 am on Jul 15, 2010 (gmt 0)

10+ Year Member



Hi

I am pulling my hair out with this one.

I am trying to redirect an old sub folder to a higher level page on my site, so in .htaccess am using:

redirect 301 /landscape-gallery/oil-paintings/ http://www.mysite.co.uk/landscape-oil.html


But when I go to the old url in my browser:

http://www.mysite.co.uk/landscape-gallery/oil-paintings/ 


the resulting url after the redirect is:

http://www.mysite.co.uk/landscape-oil.htmloil-paintings/


Am I forgetting to do something here?

Any pointers would be much appreciated.

Many thnaks

Mr M

g1smd

7:23 am on Jul 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use a RewriteRule with the [R=301,L] flags, and you'll preserve your sanity, and your remaining hair.

misterm2008

7:42 am on Jul 15, 2010 (gmt 0)

10+ Year Member



Thanks for the reply

I should have mention I'd already tried that too, which did exactly the same thing :/

Is there something wrong with my syntax?

RewriteRule /landscape-gallery/oil-paintings/ http://www.mysite.co.uk/landscape-oil.html [R=301,L]


Many thanks

Mr M

misterm2008

7:56 am on Jul 15, 2010 (gmt 0)

10+ Year Member



Fixed it.

Like a melon, I was declaring a higher level redirect before the sublevel redirect (redirect 301 /landscape-gallery/).

Swapped the order and it now works.

Thanks so much for your help :)

Mr M

g1smd

10:07 am on Jul 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Don't just swap the order, make sure that ALL of your rules use RewriteRule.

Mixing Redirect with RewriteRule can cause problems, often discussed in previous threads.