With a domain pointing to an app on Heroku, I want to set the canonical link to the main domain, not the Heroku url, when the current url is the Heroku url, and not the domain..
How do I do that and not have the canonical link there when someone goes to the site at the main domain url?
You can use one of
ENV['HTTP_HOST']
ENV['SERVER_NAME']
ENV['DOCUMENT_ROOT']
to check whether the site is your main server and if not, print out the canonical URL.
You can also take a look at the ENV
variable by dumping it out for more info:
<%= h ENV.inspect %>