We have a website and our domain is on dnsimple and server is on heroku. We configured all necessary steps with ssl both on heroku & dnsimple.
When you type any of these 4 urls to url bar it works.
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. It gives 404 error.
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;
https://www.example.com
https://example.com
http://www.example.com
http://example.com
Its been more than 24 hours btw. For internet explorer I tried to remove history and flush dns config. 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. 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.
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:
In all cases except the third one, recognize_path
will raise an error. The error will be caught by the default Rails handler and displayed as 404 (an unrecognized route results in a 404 in production).
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.