Home > php教程 > php手册 > 301重定向代码(php apache)

301重定向代码(php apache)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-25 16:46:29
Original
1648 people have browsed it

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

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^domain.com[NC] 
RewriteRule ^(.*)$ http://www.phprm.com/$1 [L,R=301]
Copy after login

php写法:

<?php
Header( "HTTP/1.1 301 Moved Permanently" ); 
Header( "Location: www.phprm.com" ); 
?>
	
Copy after login

不带index.php文件:

<?php 
$qurl = $_SERVER[&#39;REQUEST_URI&#39;]; 
//获取url,伪静态地址也能完整取得 
$qurl = str_replace("/index.php","",$qurl); 
if ($qurl!=""){ 
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: http://www.phprm.com"); 
exit();} 
?>
	
Copy after login

               
               

文章网址:

随意转载^^但请附上教程地址。

Related labels:
php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template