服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > php教程 >

301重定向代码(php apache)

时间:2016-01-31 09:46来源: 作者: 点击:
使用 HTACCESS 文件 添加吧,这是代码: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^domain.com[NC] RewriteRule ^(.*)$ //www.zuimoban.com/$1 [L,R=301] php写法: ? Header( HTTP/1.1 301 Moved Permanently );
使用 HTACCESS 文件 添加吧,这是代码:
 
Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^domain.com[NC] 
RewriteRule ^(.*)$ //www.zuimoban.com/$1 [L,R=301] 
php写法:
 
<? 
Header( "HTTP/1.1 301 Moved Permanently" ); 
Header( "Location: www.zuimoban.com" ); 
?> 
不带index.php文件:
 
<?php 
$qurl = $_SERVER['REQUEST_URI']; 
//获取url,伪静态地址也能完整取得 
$qurl = str_replace("/index.php","",$qurl); 
if ($qurl!=""){ 
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: //www.zuimoban.com"); 
exit();} 
?> 
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容