需要将 WP 博客与 Heroku 上的 Rails 应用程序链接
我有一位客户想要将他的 Rails 应用程序迁移到 Heroku。然而,客户还有一个与他的域关联的博客,该博客在 WordPress 上运行。目前,WordPress 博客与 Rails 应用程序一起运行良好,但一旦我们迁移到 Heroku,这显然是不可能的。
应用程序的网址类似于 http://mydomain.com,博客的网址类似于 http://mydomain/blog。
我意识到最好的长期解决方案是以 Rails 格式(如 Toto 或 Jekyll)重做博客。但从短期来看,继续托管 WP 博客(或其他地方)但使用 Heroku 运行应用程序的最佳方式是什么?客户不希望博客位于子域上,而是出于 SEO 原因以及博客的流量而保留在 mydomain/blog 中。我有两个想法:
在旧(非 Heroku)服务器上使用rack_rewrite 或 refraction(或者只是常规的旧 301 和 Apache mod_rewrite)将主 url 从旧站点重定向到 Heroku。在这种情况下,我可以让 WordPress 博客在原来的地方愉快地运行。我认为??如果我这样做,是否有理由选择其中一个选项(rack_rewrite、refraction 或 mod_rewrite)而不是其他选项?
切换 DNS 信息以指向 Heroku 站点,然后使用 301 重定向从博客到旧站点。但随后我必须在子域上获取旧的(非 Heroku)站点,并使用某种重写规则,这样它看起来就不是子域。
这些方法中的哪一种更可取,还是有另一种我错过的更容易的方法?
I have a client who wants to migrate his Rails app to Heroku. However the client also has a blog associated with his domain that runs on WordPress. Currently, the WordPress blog is running happily alongside the Rails app, but once we migrate to Heroku, that clearly won't be possible.
The url for the app is like http://mydomain.com, and the url for the blog is like http://mydomain/blog.
I realize that the best long-term solution is to redo the blog in a Rails format like Toto or Jekyll. But in the short term, what is the best way to continue hosting the WP blog where it is (or somewhere) but use Heroku to run the app? The client doesn't want the blog to be on a subdomain, but to remain at mydomain/blog for SEO reasons and also since there is traffic to the blog. I have two ideas:
Use rack_rewrite or refraction (or just a regular old 301 and Apache mod_rewrite) on the old (non-Heroku) server to redirect the main url from the old site to Heroku. In this case, I can just leave the Wordpress blog running happily where it is. I think?? Is there a reason to choose one of those options (rack_rewrite, refraction, or mod_rewrite) over the others if I do it this way?
Switch the DNS info to point to the Heroku site, and then use a 301 redirect from the blog to the old site. But then I'll have to get the old (non-Heroku) site on a subdomain and use some kind of rewrite rules anyway so it looks like it isn't a subdomain.
Are either of these approaches preferable, or is there another way to do it that's easier that I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
温菲尔德的回答不正确。您可以在机架服务器上运行反向代理(通过 Heroku)来直接访问博客,无论它在哪里。
请参阅 https://github.com/jaswope/rack-reverse-proxy
安装后 gem 并根据文档设置您的应用程序,您的
./config.ru
文件将具有如下内容:Winfield's answer is not correct. You can run a reverse proxy on your rack server (via Heroku) to direct to the blog, wherever it may be.
See https://github.com/jaswope/rack-reverse-proxy
After you install the gem and set up your app according to the docs, your
./config.ru
file will have something like this:唯一可行的长期/可扩展解决方案是将博客永久托管在子域或不同域上,并添加从 mydomain.com/blog 到新位置的重定向(即:blog.mydomain.com)。
您需要一台在 mydomain.com 上运行 Apache/nginx 等前端的服务器来提供 Rails 和 Wordpress 等混合后端,而这在 Heroku 上是不可能的。
遗憾的是,这就是您需要作为顾问深入研究并向客户严肃对待技术限制的地方。
为什么您的客户想要迁移到 Heroku?您可以通过控制前端并可以混合不同后端的不同托管来实现背后是否有更大的目标?
The only tenable long term/scalable solution would be to host the blog permanently on a sub-domain or different domain and add a redirect from mydomain.com/blog to the new location (ie: blog.mydomain.com).
You would need a single server running a front-end like Apache/nginx on mydomain.com to serve up mixed back-ends like Rails and Wordpress and that is not possible on Heroku.
Sadly, this is where you need to dig in as a consultant and be stern with your client about the technical limitations.
Why does you client want to migrate to Heroku? Is there a larger goal behind that you could accomplish with different hosting where you control the front-end and can mix in different back ends?
另一个解决方案是将heroku设置为http://app.example.com,将Wordpress设置为http://example.com。您将 WordPress 登陆页面放在 root 中,并将博客放在 /blog 上。当用户点击登陆页面上的“登录”或“注册”时,他们会链接到 heroku-app。
从 SEO 角度来看,这将是最佳选择,但需要一些 DNS 知识。
Another solution is to set heroku to http://app.example.com, and Wordpress to http://example.com. You put your Wordpress-landing page in the root , and blog on /blog. When the user click "login" or "signup" on the landing-page, they're linked to the heroku-app.
This will be optimal in a SEO-perspective, but require some DNS-knowledge.