易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

PHP统计网站访问次数防刷新

<?
@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 ......

php字符串比较用==的一个教训

一直认为php中字字符串比较直接用==来判断还是很方便的,但今天遇到的一个问题,彻底让我明白了使用strcmp的必要性.这个问题很多老手都可能会忽略的.
今天在登录自己做的程序时,在输入验证码后,想直接按小键盘上回车登录(程序检查了回车事件),结果按回车按成了键盘上回车键旁边小数的那个键,验证码栏就多输入了一个点。由于 ......

php获取程序执行的时间

在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 ......

JSP中include指令和include行为区别

 我们都知道在jsp中include有两种形式,分别是
<%@ include file=” ”%>
<jsp:include page=” ” flush=”true”/>
    前者是指令元素、后者是行为元素。具体它们将在何处用?如何用及它们有什么区别?这应该是很多人看 ......

jsp和Action中Base64编码转换

jsp中用javascript将中文Base64转码, Action中再用Base64解码
javascript中使用webtoolkit.base64.js,下载地址http://www.webtoolkit.info/djs/webtoolkit.base64.js
相关介绍 http://www.webtoolkit.info/javascript-base64.html
/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号