php-general Digest 17 Jun 2012 10:56:50 -0000 Issue 7858
Topics (messages 318261 through 318263):
reload page without use header
318261 by: Farzan Dalaee
318262 by: Simon Schick
318263 by: As'ad Djamalilleil
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
hi guys
is there any way to reload page without using header('location :index.php');
and javascript?
Best Regards
--- End Message ---
--- Begin Message ---
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.dal...@gmail.com>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
>
>
--- End Message ---
--- Begin Message ---
you can use header("Refresh: 60"); to refresh your current page if that
what you really need. 60 means it will be refresh in 60 seconds.
On Sun, Jun 17, 2012 at 12:06 AM, Farzan Dalaee <farzan.dal...@gmail.com>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
>
>
--- End Message ---