使用 Rack::Rewrite 重写 TLD 后面的周期
我正在使用 rack-rewrite gem 在 Rails 应用程序中重写我的 url。
我想要避免的问题之一是 TLD 后面有一个尾随句点。
http://example.com./foo
^
现在我不能 100% 确定这对 google Juice 是否重要,但对 Disqus 和我的视频播放器确实很重要,它根据请求的域验证许可证。
我看到的问题是机架环境没有在 SERVER_NAME 变量中显示这个尾随句点。
以下是我请求 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"
}
如您所见,所有变量都不包含尾随 .
在域之后。
这对于 Rack::Rewrite 来说是可能的吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论