1

I'm using the rack-rewrite gem to rewrite my urls in a Rails app.

One of the problems I want to avoid is having a trailing period after the TLD.

http://example.com./foo
                  ^

Now I'm not 100% sure if this matters for google juice or not, but it does matter for Disqus and my video player, which validates the license based on the requesting domain.

The problem I'm seeing is that the rack environment doesn't show this trailing period in the SERVER_NAME variable.

Here's what I'm seeing in the logs when I request http://example.com./foo:

[RACK ENV]:
{
   "GATEWAY_INTERFACE"=>"CGI/1.1", 
   "PATH_INFO"=>"/foo", 
   "QUERY_STRING"=>"", 
   "REMOTE_ADDR"=>"xx.xx.xx.xx", 
   "REMOTE_HOST"=>"xx.xx.xx.xx", 
   "REQUEST_METHOD"=>"GET",
   "REQUEST_URI"=>"http://example.com/foo", 
   "SCRIPT_NAME"=>"", 
   "SERVER_NAME"=>"example.com", 
   "SERVER_PORT"=>"80", 
   "SERVER_PROTOCOL"=>"HTTP/1.1", 
   "HTTP_X_VARNISH"=>"2117759881", 
   "HTTP_X_REAL_IP"=>"xx.xx.xx.xx",
   "HTTP_X_FORWARDED_FOR"=>"xx.xx.xx.xx", 
   "HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7", 
   "HTTP_HOST"=>"example.com"
}

As you can see, none of the variables includes a trailing . after the domain.

Is this even possible with Rack::Rewrite?

Ben Scheirman
  • 40,531
  • 21
  • 102
  • 137

0 Answers0