Skip to content


apache rewrite 针对目录转向

恭喜公司.com再此被百度收录。
网站改版后,由于目录和文件命名的改变,以前收录的URL就是404了,现需转发至资料备份服务器。
使用php的话效率低了,所以用apache直接转发。

 
#笨方法
<coolcode>
Redirect temp /doc/ http://222.222.222.222/doc/
Redirect temp /news/ http://222.222.222.222/news/
Redirect temp /parttimetalent/ http://222.222.222.222/parttimetalent/
Redirect temp /fulltimetalent/ http://222.222.222.222/fulltimetalent/
Redirect temp /person/ http://222.222.222.222/person/
Redirect temp /ebook/ http://222.222.222.222/ebook/
</coolcode
>

#使用正则
<coolcode>
RedirectMatch temp ^/(doc|news|parttimetalent|fulltimetalent|person|ebook)/(.*) http://222.222.222.222/$1/$2
</coolcode>

#反向代理;对图片、js等目录都需处理,比较麻烦
#需开启proxy_module和proxy_http_module,费资源
<coolcode>
ProxyPass /doc/ http://222.222.222.222/doc/
ProxyPass /Include/ http://222.222.222.222/Include/
ProxyPassReverse /doc/ http://222.222.222.222/doc/
</coolcode>

关于在转向时使用301还是302,可以参考
http://www.chinamyhosting.com/seoblog/2006/04/12/301-redirect/

如果想收录新站就用301,保持原站索引用302

Posted in Apache, 技术.

Tagged with , .


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.