简体   繁体   English

网站未将Google搜索http打开为https

[英]Website not opening google search http to https

We have a website and our domain is on dnsimple and server is on heroku. 我们有一个网站,我们的域名在dnsimple上,服务器在heroku上。 We configured all necessary steps with ssl both on heroku & dnsimple. 我们在heroku和dnsimple上都使用ssl配置了所有必需的步骤。

When you type any of these 4 urls to url bar it works. 当您在网址列中输入以下4个网址中的任何一个时,它将起作用。

But the problem is, when I search on google as my website and click on the link, it is not opening especially with internet explorer & safari. 但是问题是,当我在Google上搜索my website并单击链接时,它尤其是在Internet Explorer和Safari浏览器中没有打开。 It gives 404 error. 它给出404错误。

Error from the console; 控制台错误;

ActionController::RoutingError (No route matches "https://www.google.com.tr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwiU0JX39YnQAhWJEiwKHSq2BpQQFggcMAA&url=https%3A%2F%2Fwww.example.com%2F&usg=AFQjCNFg0D1KFk0WGvYOfUoVzNm19KDBYw&bvm=bv.137132246,d.bGg"):

I have added all 4 websites to google search console as; 我已将所有4个网站添加为google搜索控制台;

https://www.example.com
https://example.com
http://www.example.com
http://example.com

Its been more than 24 hours btw. 它已经超过24小时了。 For internet explorer I tried to remove history and flush dns config. 对于Internet Explorer,我试图删除历史记录并刷新dns配置。 Still no luck. 仍然没有运气。

EDIT: There is no checks as referrer. 编辑:没有检查作为引荐来源。 But there is a code to show header or not as in application controller but I do not think this is relevant; 但是在应用程序控制器中有一个代码可以显示标头或不显示标头,但是我认为这并不相关。

before_filter :set_locale, :location_action_name
 def location_action_name
    if !logged_in?
      url = Rails.application.routes.recognize_path(request.referrer)
      @last_controller = url[:controller]
      @last_action = url[:action]


    end
  end

EDIT2: I removed the below code and pushed to heroku now it works. EDIT2:我删除了以下代码,并将其推送到heroku,现在它可以工作了。 But why is that? 但是为什么呢?

The issue is caused by the following code fragment: 此问题是由以下代码片段引起的:

  url = Rails.application.routes.recognize_path(request.referrer)
  @last_controller = url[:controller]
  @last_action = url[:action]

As far as I remember (and I guess, given that recognize_path was removed in recent versions of Rails) recognize_path raises a routing error in case it can't find the path. 据我所记得(并且我猜,考虑recognize_path在最新版本的Rails中已删除了ognize_path), recognize_path会引发路由错误,以防找不到路径。

You are passing arbitrary strings to the function, but the function only recognizes paths internally described in the router. 您正在将任意字符串传递给该函数,但是该函数仅识别路由器内部描述的路径。

request.referrer would return 3 different types of URL: request.referrer将返回3种不同类型的URL:

  1. blank: when no referrer 空白:无推荐人时
  2. external URL: when the visitor clicks elsewhere and reaches your app 外部网址:访问者点击其他位置并到达您的应用时
  3. internal URL: when the visitor clicks somewhere in your app 内部网址:访问者点击您应用中的某个位置时

In all cases except the third one, recognize_path will raise an error. 在除第三种情况以外的所有情况下, recognize_path都会引发错误。 The error will be caught by the default Rails handler and displayed as 404 (an unrecognized route results in a 404 in production). 该错误将由默认的Rails处理程序捕获并显示为404(无法识别的路线导致404生产)。

I'm not sure what location_action_name is supposed to do, but as it is implemented now it's very fragile and in most cases it will result into causing 404 responses in your app. 我不确定location_action_name应该做什么,但是由于现在已实现,因此它非常脆弱,在大多数情况下,它将导致在您的应用中引起404响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM