301重定向代码 php apache
发布时间:2022-01-20 10:53:45 所属栏目:PHP教程 来源:互联网
导读:使用 HTACCESS 文件 添加吧,这是代码: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^domain.com[NC] RewriteRule ^(.*)$ http://www.Cuoxin.com/$1 [L,R=301] php写法: ? Header( HTTP/1.1 301 Moved Permanently ); Header( Locati
使用 HTACCESS 文件 添加吧,这是代码: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^domain.com[NC] RewriteRule ^(.*)$ http://www.Cuoxin.com/$1 [L,R=301] php写法: <? Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: www.Cuoxin.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: http://www.Cuoxin.com"); exit();} ?> ![]() (编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |