Forum Moderators: phranque

Message Too Old, No Replies

Htaccess Basic Redirect

         

jinxed

8:01 pm on Jan 2, 2011 (gmt 0)

10+ Year Member



I have the following code in a .htaccess file located in;

beta.example.com/guides/

Redirect 301 /guides/key-word.html http://beta.example.com/articles/key-word.html


The code successfully redirects the browser to the new file except the following parameters are being added to the URL:

http://beta.example.com/articles/key-word.html?url_filename=key-word


Can anyone advise why this is happening?

This code is also present with an additional RewriteCond/RewriteRule code.

Going directly to the target address is fine.

g1smd

2:32 am on Jan 3, 2011 (gmt 0)

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



When you mix Redirect and RewriteRule on the same site, the rules may not operate in the order you expect.

Change the rule currently using the Redirect directive to instead use RewriteRule with the [R=301,L] flags.

jinxed

2:39 pm on Jan 3, 2011 (gmt 0)

10+ Year Member



Thank you - problem solved!

jinxed

3:01 pm on Jan 3, 2011 (gmt 0)

10+ Year Member



After just checking Live HTTP Headers - the status code is: HTTP/1.1 200 OK - where as normally I would get the HTTP/1.1 301 Moved Permanently.

My code for the redirect was:

RewriteEngine on

RewriteRule ^key-word.html$ http://beta.example.com/articles/key-word.html [R=301,L]


Any ideas why this may be?

ADDED:

The Live HTTP Headers only shows the 200 OK code for the redirected URL, and does not show any data for the URL that is being originally typed. Is this actually how it should be? This maybe just my limited knowledge with using this tool.

jdMorgan

7:06 pm on Jan 5, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Always completely delete your browser cache before testing any new server-side code... :)

If you're doing extensive testing, then disable your cache by setting its size or lifetime to zero, but don't forget to turn it back on when you're done!

Jim

jinxed

8:46 pm on Jan 5, 2011 (gmt 0)

10+ Year Member



Thanks Jim, I've found my missing HTTP/1.1 301!

Also, thank you for the tip regarding testing.