<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>胡戈戈 &#187; 重定向</title> <atom:link href="http://hugege.com/tag/%e9%87%8d%e5%ae%9a%e5%90%91/feed/" rel="self" type="application/rss+xml" /><link>http://hugege.com</link> <description>网上吹水记录  hugege.com</description> <lastBuildDate>Sun, 06 Nov 2011 05:10:30 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>修改.htaccess实现301重定向</title><link>http://hugege.com/2008/07/01/htaccess/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=htaccess</link> <comments>http://hugege.com/2008/07/01/htaccess/#comments</comments> <pubDate>Mon, 30 Jun 2008 19:17:10 +0000</pubDate> <dc:creator>胡戈戈</dc:creator> <category><![CDATA[博客]]></category> <category><![CDATA[网络]]></category> <category><![CDATA[偶笑]]></category> <category><![CDATA[论坛]]></category> <category><![CDATA[重定向]]></category><guid isPermaLink="false">http://hugege.com/2008/07/01/htaccess/</guid> <description><![CDATA[我的偶笑论坛已经开了快两个月了，感觉对于搜索引擎很不友好，有一点就是链接不统一，由于discuz的后台没有设置将有带www和没带www中的哪一个做为主网站的功能，所以我就直接动手了，刚刚修改偶笑论坛的.htaccess文件，终于实现了将所有oxiao.com的链接直接跳转到www.oxiao.com的链接了，当然现在地址统一对于搜索引擎来说将会是非常有用的，我也不用担心我这个论坛对于搜索引擎不好了。我所用的bluehost的cpanel里面也可以直接修改，不过经过我的测试好像不行，只能跳转从http://oxiao.com/到http://www.oxiao.com/，其它的子链接不行。所以只有自己手动修改.htaccess，刚开始按照网上的说明修改，还是感觉不行，最后发现，原来这个添加是有顺序讲究的，所以大家以后在修改.htaccess的时候，如果发现不行，可以试着改变下顺序。下面为偶笑论坛的.htaccess里面的内容： # Use PHP5CGI as default AddHandler fcgid-script .php # 将 RewriteEngine 模式打开 RewriteEngine On # 修改以下语句中的 /discuz 为你的论坛目录地址，如果程序放在根目录中，请将 /discuz 修改为 / RewriteBase / # Rewrite 系统规则请勿修改 RewriteCond %{HTTP_HOST} !^www.oxiao.com$ [NC] RewriteRule ^(.*)$ http://www.oxiao.com/$1 [L,R=301] RewriteRule ^archiver/((fid&#124;tid)-[\w\-]+\.html)$ archiver/index.php?$1 RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&#38;page=$2 RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&#38;extra=page\%3D$3&#38;page=$2 RewriteRule ^space-(username&#124;uid)-(.+)\.html$ space.php?$1=$2 RewriteRule ^tag-(.+)\.html$ tag.php?name=$1 下面再转一篇不错的文章给大家看下，我就是按照下面这个来修改的。 VIA 出于SEO、PR值传递、网址转换的目的，在网站初建和网站迁移时我们都需要使用301重定向，通常包括域名对域名，目录对目录和一个独立网址对另一个独立网址的重定向。在bluehost虚拟主机上作301重定向，最常用的方法有2种： 1.直接编辑.htaccess。 2.用cPanel设定。 [...]]]></description> <content:encoded><![CDATA[<p>我的偶笑论坛已经开了<a href="http://hugege.com/2008/05/03/oxiao/">快两个月</a>了，感觉对于搜索引擎很不友好，有一点就是链接不统一，由于discuz的后台没有设置将有带www和没带www中的哪一个做为主网站的功能，所以我就直接动手了，刚刚修改偶笑论坛的.htaccess文件，终于实现了将所有oxiao.com的链接直接跳转到www.oxiao.com的链接了，当然现在地址统一对于搜索引擎来说将会是非常有用的，我也不用担心我这个论坛对于搜索引擎不好了。我所用的bluehost的cpanel里面也可以直接修改，不过经过我的测试好像不行，只能跳转从<a href="http://oxiao.com/">http://oxiao.com/</a>到<a href="http://www.oxiao.com/">http://www.oxiao.com/</a>，其它的子链接不行。所以只有自己手动修改.htaccess，刚开始按照网上的说明修改，还是感觉不行，最后发现，原来这个添加是有顺序讲究的，所以大家以后在修改.htaccess的时候，如果发现不行，可以试着改变下顺序。下面为偶笑论坛的.htaccess里面的<a href="http://hugege.com/2008/07/01/htaccess/">内容</a>：</p><p># Use PHP5CGI as default<br /> AddHandler fcgid-script .php<br /> # 将 RewriteEngine 模式打开<br /> RewriteEngine On</p><p># 修改以下语句中的 /discuz 为你的论坛目录地址，如果程序放在根目录中，请将 /discuz 修改为 /<br /> RewriteBase /</p><p># Rewrite 系统规则请勿修改</p><p>RewriteCond %{HTTP_HOST} !^www.oxiao.com$ [NC]<br /> RewriteRule ^(.*)$ http://www.oxiao.com/$1 [L,R=301]<br /> RewriteRule ^archiver/((fid|tid)-[\w\-]+\.html)$ archiver/index.php?$1<br /> RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&amp;page=$2<br /> RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&amp;extra=page\%3D$3&amp;page=$2<br /> RewriteRule ^space-(username|uid)-(.+)\.html$ space.php?$1=$2<br /> RewriteRule ^tag-(.+)\.html$ tag.php?name=$1</p><p><span id="more-112"></span></p><p>下面再转一篇不错的文章给大家看下，我就是按照下面这个来修改的。<br /> <a href="http://www.bluehost-cn.com/bluehost-domain-redirects" target="_blank">VIA</a></p><p>出于SEO、PR值传递、网址转换的目的，在网站初建和网站迁移时我们都需要使用301重定向，通常包括域名对域名，目录对目录和一个独立网址对另一个独立网址的重定向。在<strong>bluehost虚拟主机</strong>上作301重定向，最常用的方法有2种：<br /> 1.直接编辑.htaccess。<br /> 2.用cPanel设定。<br /> 实质二者都是修改文件.htaccess，只是前者手工编辑，后者是由cPanel完成。用cPanel操作相当简单，登陆你的 cPanel(bluehost虚拟主机可以选简体中文)&#8211;&gt;Domain&#8211;&gt;Redirects，选择相应的选项即可完成设置，这里暂不讨论。下面讲一下直接编辑.htaccess的方法。<br /> 注意：在设置301重定向之前务必备份相应目录下的.htaccess文件。<br /> <strong>1.重定向domain.com到www.domain.com</strong><br /> 这种重定向旨在使域名唯一，是网站SEO必须要做的，后面重定向www.domain.com到domain.com也是出于同样的原因，只是形式不同。<br /> 打开.htaccess文件，加入以下规则。(下面的规则是针对主域名的，子域名要修改)</p><p><code>RewriteEngine On<br /> RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]<br /> RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]<br /> </code></p><p><strong>2.重定向www.domain.com到domain.com</strong></p><p><code>RewriteEngine On<br /> RewriteCond %{HTTP_HOST} !^domain.com$ [NC]<br /> RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]<br /> </code></p><p><strong>3.重定向olddomain.com到www.newdomain.com</strong></p><p><code>RewriteEngine On<br /> RewriteCond %{HTTP_HOST} !olddomain.com$ [NC]<br /> RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]<br /> </code></p><p><strong>4.重定向olddomain.com to newdomain.com</strong></p><p><code>RewriteEngine On<br /> RewriteBase /<br /> RewriteCond %{HTTP_HOST} !olddomain.com$ [NC]<br /> RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]<br /> </code></p><p><strong>5.重定向domain.com/file/file.php 到 otherdomain.com/otherfile/other.php</strong></p><p><code>RewriteCond %{HTTP_HOST} ^www.domain.com$<br /> RewriteRule ^file/file.php$ http://www.otherdomain.com/otherfile/other.php [R=301,L]</code></p><p><a href="http://hugege.com/" target="_blank">Hugege.com</a> by 胡戈戈 Copyright ©  2008 爱祖国,爱人民,唉派对。<br /> 更多精彩欢迎您订阅<a href="http://feed.hugege.com" target="_blank">http://feed.hugege.com</a><br/> <a href="http://www.gegehost.com/" target="_blank">GegeHost稳定便宜的美国主机</a>,论坛推荐:<a href="http://ushost.me/" target="_blank">美国主机论坛</a></p> ]]></content:encoded> <wfw:commentRss>http://hugege.com/2008/07/01/htaccess/feed/</wfw:commentRss> <slash:comments>41</slash:comments> </item> </channel> </rss>
