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 ......
×÷Õß: laruence(http://www.laruence.com
)
±¾ÎĵØÖ·: http://www.laruence.com/2010/05/04/1450.html
תÔØÇë×¢Ã÷³ö´¦
ÔÚ´óÐ͵ÄWebÏîÄ¿ÖÐ, include_pathÊÇÒ»¸öÄ£¿é»¯Éè¼ÆµÄ¸ù±¾Öеĸù±¾(µ±È»,ÏÖÔÚÒ²Óкܶà»ùÓÚautoloadµÄÉè¼Æ,
Õâ¸ö²»Ó°Ïì±¾ÎĵÄ̽ÌÖ), µ«ÊÇÕýÊÇÒòΪinclude_path, ¾³£»áÈÃÎÒÃÇÓöµ½Ò»Ð©ÒòΪûÓÐÕÒµ½Õ ......
tomcat ĬÈÏʹÓõÄ×Ö·û¼¯ÊÇISO-8859-1£¬²»Ö§³ÖÖÐÎÄ×Ö·û£¬ËùÒÔÔÚÏÖʵÖÐÎÄʱÐèҪת»»×Ö·ûºÍÉèÖÃ×Ö·û¼¯¡£
server.mxl¸ÄΪ<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> £¬Ìí¼Ó´úÂëת»»×Ö·ûString.getBytes("ISO-8859-1"),"UTF-8 ......
Ô´´úÂ룬a.jspÍùb.jsp´«Öµ£º
a.jspÒ³ÃæÄÚÈÝ
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<form action="b.jsp">
¡¡¡¡name:<input type=text name=name>
¡¡¡¡<input type=submit>
</form>
b.jspÒ³ÃæÄÚÈÝ£º
<%@ page language="java" import="java.ut ......
µ±ÔÚJSPµÄpageÖ¸ÁîÖÐÉèÖÃerrorPage="url"¾Í¿ÉÒÔÉèÖô¦ÀíÒ쳣ʼþµÄJSPÎļþ¡£Èç¿ÉÒÔÕâÑùд£º
<%@ page errorPage="error.jsp" %>
ÕâÑùµÄ»°£¬µ±Ò³ÃæÖгöÏÖÒì³£µÄÊ ......