Re: Header Redirect
| From: | Robert Cummings | Date: | Tue, 27 May 2008 16:54:09 +0000 |
| Subject: | Re: Header Redirect | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-274742@lists.php.net to get a copy of this message | ||
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
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.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP