当前位置:web 服务器 > Apache >>

301重定向代码(php apache)

使用 HTACCESS 文件 添加吧,这是代码

Options +FollowSymLinks

RewriteEngine on

RewriteCond %{HTTP_HOST} ^domain.com[NC]

RewriteRule ^(.*)$ http://www.zhaoxi.net/$1 [L,R=301]

php教程写法

<?
  Header( "HTTP/1.1 301 Moved Permanently" );
  Header( "Location: www.zhaoxi.net" );
  ?>

不带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: http://www.zhutiai.com");
exit();}
?>

补充:Php教程,Php入门 
Apache
IIS
Nginx
Tomcat
如果你遇到web 服务器难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,