PHP 301 Redirect Function | PHP 302 Redirect ...
来源:百度文库 编辑:神马文学网 时间:2024/04/28 17:04:19
PHP redirect function (301 / 302)
redirect('http://www.domain.com', 301);
function redirect($url, $type=301)
{
if ($type == 301) header("HTTP/1.1 301 Moved Permanently");
header("Location: $url");
echo 'This page has moved to '.$url.'';
exit();
}
Jojo::redirect('http://www.domain.com');
Feel free to send a link my way if you find this useful.
PHP redirect function (301 / 302)
<< Alternative domains not in Google Sending clients to Google >>Apr 30, 2008
I'm often asked how to do 301 redirects in PHP. It's not hard, but it's a pain having to remember the exact syntax every time. Here's a little function I wrote for Jojo CMS for making redirects easy.Usage
Add one line of code whenever you need to do a redirect.301 redirects...
redirect('http://www.domain.com');orredirect('http://www.domain.com', 301);
302 redirects...
redirect('http://www.domain.com', 302);The function
You will need to include this code in your PHP script to be able to use this redirect function.function redirect($url, $type=301)
{
if ($type == 301) header("HTTP/1.1 301 Moved Permanently");
header("Location: $url");
echo 'This page has moved to '.$url.'';
exit();
}
Jojo users
This function is available as part of Jojo CMS. Simply place "Jojo::" before the function call eg...Jojo::redirect('http://www.domain.com');
Not so hard
There we go. A little function that makes a reasonably simple job very simple. It's saved me lots of time having to remember the exact syntax for a 301 redirect.Feel free to send a link my way if you find this useful.
PHP 301 Redirect Function | PHP 302 Redirect ...
301 Redirect 永久重定向的实现
301 Redirect 永久重定向的实现
forward和redirect
Forward versus redirect
Response.Redirect的使用
php
JSP中的redirect和forward
Kallahar‘s Place: PHP XSS (cross site scripting) filter function
Response.Redirect和Server.Transfer的区别
Redirect the Enter key from a Windows Forms T...
jsp中jsp:forward 与 redirect区别_一路飞扬
php 跳转
PHP & memcached
php教程
php编码
php实验室
socket.php
php语法
PHP echo
PHP 文件锁flock - 聊聊PHP - php,freebsd,javascript
适用于 php-5.2 的 php.ini 中文版
新手如何学习PHP-PHP基础
Don‘t redirect after setting a Session variable (or do it right)