开发者

How to specify canonical link in app on heroku when another domain points to it

开发者 https://www.devze.com 2023-01-22 15:53 出处:网络
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..

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 ther开发者_如何学运维e 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 %>
0

精彩评论

暂无评论...
验证码 换一张
取 消