[LRUG] FW: Redirects on heroku
John Beynon
john at beynon.org.uk
Tue Aug 3 05:32:30 PDT 2010
this what we do (off live Heroku app) for something similar (without the
requested path being passed through) I guess it could be modified to pass
the requested path pretty easily though;
application controller;
before_filter { |c| ensure_domain if Rails.env =='production' }
def ensure_domain
if request.env['HTTP_HOST'] != TheDomain
redirect_to 'http://' + TheDomain
end
end
and then have the domain set in the production.rb
TheDomain = 'www.greatlittleideas.com'
i think we too followed the Heroku guide and came across the behaviour you
are seeing too so tweaked it slightly.
hth
john.
On Tue, Aug 3, 2010 at 1:19 PM, Anthony Green <Anthony.Green at bbc.co.uk>wrote:
>
> Can any heroku users know what the answer is ?
>
>
> ------ Forwarded Message
> From: Michael Smethurst <
> Subject: Redirects on heroku
>
> Hiya
>
> Just following on from lunchtime chat...
>
> I've managed to get cctvspotr running on heroku and set it up with 2 custom
> domains: www.cctvspotr.org and cctvspotr.org
>
> I've registered www.cctvspotr.org and pointed it at heroku's dns. All fine
>
> http://www.cctvspotr.org
> http://cctvspotr.org
>
> Now I'd like to get cctvspotr.org{/whatever} to 301 to
> www.cctvspotr.org{/whatever}. But can't find any helpful hints. The
> nearest
> I found was:
>
>
> http://docs.heroku.com/custom-domains#redirecting-traffic-to-specific-domain
>
> I tried adding that code to my application controller with TheDomain =
> 'www.cctvspotr.org' but that just redirected cctvspotr.org to
> cctvspotr.orgwww.cctvspotr.org
>
> Am sure there's a proper forum to ask this on somewhere but not sure where
>
> Any help much appreciated
>
> Cheers
> michael
>
> ------ End of Forwarded Message
>
>
> http://www.bbc.co.uk/
> This e-mail (and any attachments) is confidential and may contain personal
> views which are not the views of the BBC unless specifically stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in reliance
> on it and notify the sender immediately.
> Please note that the BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20100803/44b7b704/attachment-0003.html>
More information about the Chat
mailing list