常规问题解决方法,重定向

常见问题:
1、内容重复的URL
2、链接均匀分布/传递
3、追溯SERP指向链接

如何去实现呢?

301 redirect
301帮助网站控制URL,该状态在头部请求时发生,本意为永久重定向在指定页面上。他容许有目的的链接定向方案;

apache 301 redirect implementation

在apache服务端,配置更新htaccess文件(.htaccess),该文件容许用户自行设置301redirect commands,非常容易实现你可以通过notepad来实现。

redirect commands:
Redirect 301 /oldpage.html http://www.site.com/newpage.html

无www的页面处理定位到有www的页面。
RewriteEngine on
reweitecond %{http_host}^site.com[nc]
rewriterule ^(.*)$http://www.site.com/$1 [r=301,nc]


Windows IIS 301 Redirect Implementation

In the Windows server environment you have a GUI that has helped to simplify some of the tasks of managing a web server. To handle 301 redirection on a Windows server follow these steps:

   1. In IIS Manager you want to navigate to the site, directory, file you want to redirect then right-click and select Properties.
   2. In the Properties you want to find the Directory tab (sometimes labeled Home or Virtual Directory)
   3. In the top set of radio buttons under "Content for this source should come from" select A redirection to a URL
   4. In the Redirect to: text field enter the full path of the new page URL
   5. In the bottom checkboxes be sure to check both the "The exact URL entered above" and "A permanent redirection for this resource"
   6. Finalize it with the Apply button

代码层也通过程序来实现:
Coded 301 redirects should be used when you do not have privileges to make redirects at the server level.

Here are examples for some of different languages:

PHP

<?Header( "HTTP/1.1 301 Moved Permanently" );

Header( "Location: http://www.site.com/" );?>

ASP

<%@ Language=VBScript %>

<%

Response.Status="301 Moved Permanently"

Response.AddHeader "Location","http://www.site.com/"

%>

JSP

<%

response.setStatus(301);

response.setHeader( "Location", "http://www.site.com/" );

response.setHeader( "Connection", "close" );

%>

ColdFusion

<cfheader statuscode=”301″ statustext=”Moved permanently” />

<cfheader name=”location” value=”http://www.mysite.com/new-location-for-content/” />

When coding 301 redirects into pages be sure that it is the very first code that is executed on the page. Since you are modifying the headers through the code




你可能感兴趣的:(windows,VBScript,asp,IIS,ColdFusion)