Re: reload page without use header

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

 



Hi, Farzan

Redirecting is something you can do in a way the user doesn't see anything
(I call them server-side redirects) and in a way the user get's informed
that the url has changed (I call them client-side redirects).

What I mean with server-side (mostly called internal redirects) is if the
user requests a page, you can do stuff with mod_rewrite (in Apache) or some
equal webserver-module to call another file than requested. The user will
not get any notice about that.

Client-side redirects can be done using the HTTP-header (see
list-of-http-status<http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection>),
JavaScript (please think also about a non-js solution) and by using a HTML-Meta
tag <http://en.wikipedia.org/wiki/Meta_refresh>.
In my opinion the best way to do a redirect, where the user gets noticed
about, is the HTTP-header. This can be set f.e by your webserver or by a
php-script.

Example for PHP-script:

header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://www.new-url.com"; );

As far as I know, this is the only way to let other services (f.e. a
search-engine) know that this page has been moved permanently (or
temporarily) to another url.
That's the reason why I use the header-command (incl. setting the
HTTP-Status explicitly). If you don't set the HTTP-header, it will be added
(by PHP or your webserver). In my case, I use PHP 5.4 and nginx 1.2.1, the
header-code 302 is added if I don't set it.

May there are more ways to set redirects, but this are the one I know of.

Bye
Simon

On Sun, Jun 17, 2012 at 10:06 AM, Farzan Dalaee <farzan.dalaee@xxxxxxxxx>wrote:

> hi guys
> is there any way to reload page without using header('location
> :index.php'); and javascript?
> Best Regards
>
>
> --
> 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