重定向Heroku上静态资产的子域 [英] Redirecting subdomain for static assets on Heroku
问题描述
我希望myapp.com/blog重定向到www.myapp.com/blog.我已经安装了Refraction在Rack层进行子域重定向.在/blog的Heroku上这不起作用,因为/blog中的文件是静态资产.可以解决吗?
I would like myapp.com/blog to redirect to www.myapp.com/blog. I've installed Refraction to do subdomain redirects at the Rack layer. That doesn't work on Heroku for /blog since my files in /blog are static assets. Any fix?
推荐答案
像您这样的声音可能会使此操作变得比原来更困难.
Sounds like you may be making this more difficult than it needs to be.
如果只想将myapp.com/something
重定向到www.myapp.com/something
,则转到当前正在处理myapp.com
域的域主机,并创建URL重定向记录来执行此操作.这样,重定向会在域注册商甚至没有接触到Heroku服务器之前进行(这是应该如何处理的).
If you just want myapp.com/something
to redirect to www.myapp.com/something
, then goto the domain host that is currently handling the myapp.com
domain and create a URL redirect record to do just that. This way, the redirect happens at the domain registrar before it even touches your Heroku server (which is how it should be handled).
一个例子是在您的域名注册机构(例如GoDaddy,NameCheap等)创建以下记录:
An example of this would be to create the following records at your domain registrar (i.e. GoDaddy, NameCheap, etc): http://i.imgur.com/FJrMV.png
这3个IP地址指向Heroku的服务器.如果确实有一些类似于myapp.com
而不是myapp.heroku.com
Those 3 IP addresses point to Heroku's servers. You should have already set up the custom domain add-on within Heroku if indeed you have some site similar to myapp.com
and not myapp.heroku.com
这是Heroku的文章/视频,其中也涉及到了一点: http: //devcenter.heroku.com/articles/custom-domains
Here's an article / video from Heroku that deals with a little bit of this as well: http://devcenter.heroku.com/articles/custom-domains
这篇关于重定向Heroku上静态资产的子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!