我目前在www.mydomain.com上有一个wordpress网站,有超过3500篇文章(= V1)
我开发了一个新版本100%Ruby on Rails(= V2)
我想:
访问V2
最好的方法是在不丢失从V1获得的所有SEO的情况下继续进行(例如:当访问者在Google上搜索旧文章时,应该可以从archive.mydomain.com/article-path访问)。< / p>
感谢您的帮助
答案 0 :(得分:1)
我不是Ruby专家,但您可以尝试这样的事情:
#If page not found
def not_found
# Check if page that user want to access is available at your old website
require "net/http"
url = URI.parse("http://archives.mydomain.com/some-article")
req = Net::HTTP.new(url.host, url.port)
res = req.request_head(url.path)
# If it's available, redirect user to old website
if(res.code == "200")
redirect_to "http://archives.mydomain.com/some-article", :status => :moved_permanently
else
raise ActionController::RoutingError.new('Not Found')
end