新闻建站cms系统、政府cms系统定制开发

广州网站建设公司-阅速公司

asp.net新闻发布系统、报纸数字报系统方案
/
http://www.ysneo.com/
广州网站建设公司
您当前位置:首页>网站技术

网站技术

利用IIS目录改版实现301转向(全站重定向)

发布时间:2014/10/15 20:27:24  作者:Admin  阅读:542  

广告:阿里云采购优惠专区

1. 利用程序跳转

asp.net 3.1

#region 301转向

public static void To301(string path)

{

HttpContext.Current.Response.Clear();

HttpContext.Current.Response.StatusCode = 301;

HttpContext.Current.Response.AppendHeader("location", path);

HttpContext.Current.Response.End();

}

#endregion

asp 301

<%@ Language=VBScript %>

<%

Response.Status=”301 Moved Permanently”

Response.AddHeader “Location”, “http://www.****.cn/articles/301/”

%>

php 301

header(”HTTP/1.1 301 Moved Permanently”);

header(”Location: http://www.****.cn/articles/301/”);

exit();

jsp 301

<%

response.setStatus(301);

response.setHeader( “Location”, “http://www.****.cn/” );

response.setHeader( “Connection”, “close” );

%>

2. 利用服务器iis实现转向

iis,在要转向的目录(原目录不要删)右键,属性-重定向到url,如:加$s$q参数

http://demo.53bk.com/shouji$S$Q  (注意:S和Q一定要大写,不然不生效)

上面准确的url和资源永久重定向打勾。

3. IIs8.5和iis 7.5 :

要建一个目录:里面web.cofig

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://zaoyuan.ysneo.com$S$Q" exactDestination="true" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>

http重定向---将请求重定向到此目标---http://www.ysneo.com$S$Q (将所有请求重定向到确切的目标(而不是相对于目标)打勾,状态代码设为永久( 301))

4、Apache下301转向代码

新建.htaccess文件,输入下列内容(需要开启mod_rewrite):

1)将不带WWW的域名转向到带WWW的域名下

Options +FollowSymLinks

RewriteEngine on

RewriteCond %{HTTP_HOST} ^lesishu.cn [NC]

RewriteRule ^(.*)$ http://www.****.cn/$1 [L,R=301]

2)重定向到新域名

Options +FollowSymLinks

RewriteEngine on

RewriteRule ^(.*)$ http://www.****.cn/$1 [L,R=301]

3)使用正则进行301转向,实现伪静态

Options +FollowSymLinks

RewriteEngine on

RewriteRule ^news-(.+)\.html$ news.php?id=$1

将news.php?id=123这样的地址转向到news-123.html

5、Apache下vhosts.conf中配置301转向

为实现URL规范化,SEO通常将不带WWW的域名转向到带WWW域名,vhosts.conf中配置为:

<VirtualHost *:80>

ServerName www.****.cn

DocumentRoot /home/lesishu

</VirtualHost>

<VirtualHost *:80>

ServerName lesishu.cn

RedirectMatch permanent ^/(.*) http://www.****.cn/$1

</VirtualHost>

 

 

广告:阿里云新人采购专场

相关文章
iis转向
301转向
cms新闻系统购买咨询
扫描关注 广州阅速软件科技有限公司
扫描关注 广州阅速科技