Re: Header Redirect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2008-05-27 at 18:04 +0100, Stut wrote:
> On 27 May 2008, at 17:54, Robert Cummings wrote:
> > On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:
> >> On 27 May 2008, at 17:06, Yui Hiroaki wrote:
> >>> I would like to have some question.
> >>>
> >>> For example,
> >>> I am in http://example.com/?12324242
> >>>
> >>> I would like to REDIRECT from  http://example.com/?1312323232
> >>> to  http://example.com/
> >>>
> >>> I can REDIRECT from http://example.com/index.php to http://example.com
> >>>
> >>>
> >>> Please do tell me how I can redirect!
> >>>
> >>>
> >>> This is the sample what I test below!
> >>>
> >>> <?php
> >>> if ($_SERVER['REQUEST_URI'] == '/index.php') {
> >>> header("HTTP/1.1 301 Moved Permanently");
> >>> header("Location: http:///example.com/";);
> >>> exit();
> >>> }
> >>> ?>
> >>
> >> 1) Why? Redirects should be avoided where possible for performance
> >> reasons.
> >
> > Didn't this topic get covered several months back. I always do  
> > redirects
> > so as not to bugger browser history, titles, indexing, etc. If someone
> > requests a page and they need to be logged in, I redirect to the login
> > page, I never just present the login page... that's just incorrect  
> > from
> 
> Personally I tend to only use redirects when a form handler has done  
> it's job to avoid evil messages when the user hits back. However, I  
> have used both redirected and non-redirected login workflows in the  
> past for various reasons, and I don't believe there is a "standard"  
> way to do it. It depends on how the site will be used and by whom.
> 
> > a hierarchical and semantic point of view. Similarly, if I'm doing 404
> > handling with fuzzy request sniffing to determine what was actually
> > requested, I again perform a redirect once I've ascertained what was
> > probably desired. If you don't, then Google and other search engines
> > will index these malformed URLs instead of the correct URL.
> 
> The correct response to a 404 page is 404. No arguments. If you  
> redirect missing pages then your site effectively contains an infinite  
> number of pages. By all means display a useful page when you return  
> your 404 but not marking it as a missing page does little if anything  
> for your SEO rank and absolutely nothing for your users.

404 "Not Found", but it was found, but it's not where you asked for it,
it's over there... we've permanently moved it from here to there (even
if only virtually)... let's redirect you to the correct location. Since
you perform a redirect to the correct location, the content is
appropriately indexed where it actually exists. If you return a 404
status I'm pretty sure Google discards the content.

> IMHO if you're going to use a semantic argument to defend one point  
> you need to carry that attitude throughout.

My semantic argument is still intact. If I found it, then it's not
deserving of "404 Not Found" status. Sure it may not be at the requested
location, but that's what the moved status is for.

Here's a physical world analogy. Walk into a hardware store ask for
object X. If they have it they will tell you. If they don't then either
they will say, "Sorry, we don't have that. I don't have a clue where you
can get it", or if they do know (and want to help) they'll say "It's
over there at Rob's Hardware Store". What they almost certainly won't
say is hang on, then run over to Rob's hardware Store, buy item X, come
back and try to sell it to you. Almost certainly, but who knows, people
do weird things sometimes :)

So here's something else since you played the performance card. Click on
the following link and tell me where you end up when not already logged
in:

    http://mail.google.com/mail/

I'm sure Google had a good reason for that behaviour, as in it's follows
more correctly the standard expected request behaviour, and I'm sure
they get a LOT of hits ;)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux