一般我们在网站维护的时候都会设定一个页面告诉用户,正在维护中,但是怎么样的使用最方便呢?
如果是框架程序的话,最方便了.因为.htaccess中都是指向到 index.php的.在index.php中header跳转一下就OK了
但,究竟怎样写比较好,header怎么写呢?
- <?php
- // 301 Moved Permanently
- header("Location: /foo.php",TRUE,301);
- // 302 Found
- header("Location: /foo.php",TRUE,302);
- header("Location: /foo.php");
- // 303 See Other
- header("Location: /foo.php",TRUE,303);
- // 307 Temporary Redirect
- header("Location: /foo.php",TRUE,307);
- ?>
看着,header是有第三个参数的,为什么要指定参数呢?
The HTTP status code changes the way browsers and robots handle redirects, so if you are using header(Location:) it's a good idea to set the status code at the same time. Browsers typically re-request a 307 page every time, cache a 302 page for the session, and cache a 301 page for longer, or even indefinitely. Search engines typically transfer "page rank" to the new location for 301 redirects, but not for 302, 303 or 307. If the status code is not specified, header('Location:') defaults to 302.
当然,一般情况下,都是302...这是第一篇,介绍相对简单一点
还有第二篇,等 我转载好再说,哈哈