dezzy
dezzy

Reputation: 495

What is the correct HTTP redirect status code?

I have implemented friendly URL's on my site and I can access products and categories in two ways via the URL.

  1. http://www.example.com/home/electronics/tablets
  2. http://www.example.com/tablets

Now when URL http://www.example.com/tablets is navigated to, it does a permanent redirect (301) to http://www.example.com/home/electronics/tablets but is this the correct redirect code?

I was thinking maybe it should be a 303? Any suggestions would be kindly appreciated.

Upvotes: 3

Views: 869

Answers (3)

Catherine Hwang
Catherine Hwang

Reputation: 1030

You can use HTTP 302. It's pretty standard.

Edit: 301 is definitely correct as it's a permanent redirect. I misread the question.

Upvotes: 0

Quentin
Quentin

Reputation: 943089

301 is correct. You are always going to be redirecting there.

302 is inappropriate, you want the result to be cached.

303, to quote the specification, "exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource." So that isn't suitable either.

Upvotes: 2

Julian Reschke
Julian Reschke

Reputation: 41997

It depends on whether it's a permanent (301) or a temporary (302) redirection. In practice, it doesn't make a significant difference in browsers.

Why do you think that 303 is suitable?

Upvotes: 3

Related Questions