存档

作者存档

美国godaddy主机win IIS空间301转向

2010年8月31日 素依 没有评论

如何实现网站域名301重定向呢,网上给出的方法有很多:
Apache服务器的.htaccess实现301重定向

RewriteEngine on
RewriteCond %{http_host} ^ifenwen.com [NC]
RewriteRule ^(.*)$ http://www.ifenwen.com/$1 [L,R=301]

IIS服务器实现301重定向:

用ASP/PHP实现301重定向:

ASP:
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http://www.ifenwen.com/”
Response.End
PHP:
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location:http://www.ifenwen.com/”);
exit();

可惜这些方法对我都不试用,因为是win主机,所以无法设置.htaccess文件;因为不是独立主机,所以无法进行IIS设置;而对于asp/php方法,也尝试失败。

突然想到以前设置WordPress固定链接的时候用到一个文件:web.config。而所有和链接修改的设置都是在这里面,那要实现301重定向,把不带www的ifenwen.com重定向到带www的www.ifenwen.com是不是也可以在这里面设置呢?有了这样一个思路,参考原先web.config文件里书写规则,便完美实现了Godaddy免费Win主机301重定向。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="wordpress" patternSyntax="Wildcard">
          <match url="*"/>
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
          </conditions>
          <action type="Rewrite" url="index.php"/>
        </rule>
	<rule name="WWW Redirect" stopProcessing="true">
              <match url=".*" />
                 <conditions>
                    <add input="{HTTP_HOST}" pattern="^ifenwen.com$" />
                 </conditions>
              <action type="Redirect" url="http://www.ifenwen.com/{R:0}"
                 redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

其中红色部分便是新加代码用以实现301重定向,其余部分不动。

做好301重定向之后,可以检测一下成功与否:

国外的:http://www.internetofficer.com/seo-tool/redirect-check/

关于素依博客

2010年8月31日 素依 1 条评论

因为使用godaddy的免费空间,前段时间被墙了,所以就不断切换空间的系统,结果不知道何原因,发现切换了2次后就不能切换了,然后只有关闭免费空间重新开通。在备份的时候因为不能登录博客后台导出数据,于是在SQL那里导出了数据,没想到导入的时候遇上难题了,不能导入超过1MB的数据库,晕倒。

可怜我之前博客数据啊!

分类: 个人日志 标签: