301Öض¨ÏòÉèÖü°³ÌÐò´úÂëʵÏÖÈ«¼¯(ASP|.NET|PHP|JSP)
Ê×ÏÈÉêÃ÷£ºÕâ¸öÊÇÎÒתÔصģ¬ÖÂÁ¦ÓÚΪÏñÎÒÒ»ÑùµÄÐÂÊÖÌṩ°ïÖú£¡
1¡¢IISÏÂ301ÉèÖà InternetÐÅÏ¢·þÎñ¹ÜÀíÆ÷ -> ÐéÄâĿ¼ -> Öض¨Ïòµ½URL£¬ÊäÈëÐèҪתÏòµÄÄ¿±êURL£¬²¢Ñ¡Ôñ“×ÊÔ´µÄÓÀ¾ÃÖض¨Ïò”¡£
2¡¢ASPϵÄ301תÏò´úÂë
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, “http://www.xuehi.com/articles/301/”
%>
3¡¢ASP.NetϵÄ301תÏò´úÂë
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.xuehi.com/articles/301/“);
}
</script>
4¡¢PHPϵÄ301תÏò´úÂë
header(”HTTP/1.1 301 Moved Permanently”);
header(”Location: http://www.xuehi.com/articles/301/”);
exit();
5¡¢CGI PerlϵÄ301תÏò´úÂë
$q = new CGI;
print $q->redirect(”http://www.new-url.com/”);
6¡¢JSPϵÄ301תÏò´úÂë
<%
response.setStatus(301);
response.setHeader( “Location”, “http://www.xuehi.com/” );
response.setHeader( “Connection”, “close” );
%>
7¡¢ApacheÏÂ301תÏò´úÂëн¨.htaccessÎļþ£¬ÊäÈëÏÂÁÐÄÚÈÝ£¨ÐèÒª¿ªÆômod_rewrite£©£º
1£©½«²»´øWWWµÄÓòÃûתÏòµ½´øWWWµÄÓòÃûÏÂOptions +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^lesishu.cn [NC]
RewriteRule ^(.*)$ http://www.xuehi.com/$1 [L,R=301]
2£©Öض¨Ïòµ½ÐÂÓòÃûOptions +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.xuehi.com/$1 [L,R=301]
3£©Ê¹ÓÃÕýÔò½øÐÐ301תÏò£¬ÊµÏÖα¾²Ì¬Options +FollowSymLinks
RewriteEngine on
RewriteRule ^news-(.+)\.html$ news.php?id=$1½«news.php?id=123ÕâÑùµÄµØַתÏòµ½news-123.html
8¡¢ApacheÏÂvhosts.confÖÐÅäÖÃ301תÏòΪʵÏÖURL¹æ·¶»¯£¬SEOͨ³£½«²»´øWWWµÄÓòÃûתÏòµ½´øWWWÓòÃû£¬vhosts.confÖÐÅäÖÃΪ£º<VirtualHost *:80>
ServerName www.xuehi.com
DocumentRoot /home/lesishu
</VirtualHost><VirtualHost *:80>
ServerName lesishu.cn
Redirec
Ïà¹ØÎĵµ£º
<?
@session_start();
$counter = intval(file_get_contents("counter.dat"));
if(!$_SESSION['jingyun'])
{
$_SESSION['jingyun'] = true;
$counter++;
$fp = fopen("counter.dat","w");
fwrite($fp, $counter);
fclose($fp);
}
?>
×Ü·ÃÎÊ <span style="font-size:14px; color:#FF6600" mce_sty ......
Í·²¿µ÷ÓÃ
<?
require('conn.php');
$sql1="select id from news";
$query1=mysql_query($sql1,$conn);
$sun_num=mysql_num_rows($query1);
$gs=20;
$page_num=ceil($sun_num/$gs);
include("../subpage.php");
//´«¹ýÀ´µÄÒ³Êý²ÎÊý
$PB_page=$_GET['PB_page'];
if ($PB_page==1 or empty($PB_page)){
$ ......
×÷Õß: laruence(http://www.laruence.com
)
±¾ÎĵØÖ·: http://www.laruence.com/2010/05/04/1450.html
תÔØÇë×¢Ã÷³ö´¦
ÔÚ´óÐ͵ÄWebÏîÄ¿ÖÐ, include_pathÊÇÒ»¸öÄ£¿é»¯Éè¼ÆµÄ¸ù±¾Öеĸù±¾(µ±È»,ÏÖÔÚÒ²Óкܶà»ùÓÚautoloadµÄÉè¼Æ,
Õâ¸ö²»Ó°Ïì±¾ÎĵÄ̽ÌÖ), µ«ÊÇÕýÊÇÒòΪinclude_path, ¾³£»áÈÃÎÒÃÇÓöµ½Ò»Ð©ÒòΪûÓÐÕÒµ½Õ ......
ÔÚhead.htmÖмÓÈ룬Ҳ¾ÍÊÇÔÚĬÈÏÄ£°æÖÐÌí¼Ó“$stime=microtime(true); //»ñÈ¡³ÌÐò¿ªÊ¼Ö´ÐеÄʱ¼ä”
¾ä
<!--<?php
$stime=microtime(true); //»ñÈ¡³ÌÐò¿ªÊ¼Ö´ÐеÄʱ¼ä
$GuideFid[$fid]=str_replace("<a href='$webdb[www_url]' class='guide_menu'>>Ê×Ò³</a>","",$GuideFid[$fid]);
$f ......