|
|
| 第1行: |
第1行: |
| - | *PHP 301转向代码
| + | #dedirect [[301转向代码]] |
| - | | + | |
| - | <?php
| + | |
| - | header("HTTP/1.1 301 Moved Permanently");
| + | |
| - | header("Location: http://www.idcspy.org/newpage.html");
| + | |
| - | exit();
| + | |
| - | ?>
| + | |
| - | | + | |
| - | *ASP 301转向代码
| + | |
| - | | + | |
| - | <%@ Language=VBScript %>
| + | |
| - | <%
| + | |
| - | Response.Status="301 Moved Permanently"
| + | |
| - | Response.AddHeader "Location", "http://www.idcspy.org"
| + | |
| - | %>
| + | |
| - | | + | |
| - | *Coldfusion 301转向代码
| + | |
| - | 下面代码保存为oldpagename.cfm
| + | |
| - | <.cfheader statuscode="301" statustext="Moved permanently">
| + | |
| - | <.cfheader name="Location" value="http://www.idcspy.org/newpage.html">
| + | |
| - | | + | |
| - | *ASP.NET 301转向代码
| + | |
| - | | + | |
| - | private void Page_Load(object sender, System.EventArgs e)
| + | |
| - | {
| + | |
| - | Response.Status = "301 Moved Permanently";
| + | |
| - | Response.AddHeader("Location","http://www.idcspy.org");
| + | |
| - | }
| + | |
| - | | + | |
| - | *规范WWW(利用.htaccess实现301转向)
| + | |
| - | 如果是Linux服务器,并且ApacheMod-Rewrite开启的时候,你可以在网站跟目录中创建.htaccess文件,通过.htaccess可以把所有收录为idcspy.org的链接修改为www.idcspy.org,
| + | |
| - | .htaccess必须放在网站所在的目录中(即网站首页在同一个文件夹内),请把下面的代码写入.htaccess文件
| + | |
| - | RewriteEngine on
| + | |
| - | rewritecond %{http_host} ^idcspy.org [nc]
| + | |
| - | rewriterule ^(.*)$ http://www.idcspy.org/$1 [r=301,nc]
| + | |
| - | | + | |
| - | *IIS中实现301重定向
| + | |
| - | | + | |
| - | 如果你的是Windows服务器,可以通过设置IIS实现301重定向
| + | |
| - | 点击the Internet Services Manager,然后选择需要重定向的文件或文件夹
| + | |
| - | 鼠标右键,选择 a redirection to a URL.
| + | |
| - | 指定要重定向的文件名
| + | |
| - | 选择 The exact URL entered above.
| + | |
| - | 选择 A permanent redirection for this resource.
| + | |
| - | 点击 Apply. 设置完成!
| + | |
| - | | + | |
| - | *301转向 domain.com 到 www.domain.com代码
| + | |
| - | RewriteEngine On
| + | |
| - | RewriteBase /
| + | |
| - | RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
| + | |
| - | RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
| + | |
| - | | + | |
| - | *301转向 www.domain.com 到 domain.com .htaccess代码:
| + | |
| - | RewriteEngine On
| + | |
| - | RewriteBase /
| + | |
| - | RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
| + | |
| - | RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
| + | |