How to get request referer path?

前端 未结 2 1298
渐次进展
渐次进展 2020-11-30 01:57

I need the path of the referrer. I don\'t want the domain name. For example, if the referrer is http://www.google.com/adsense I want /adsense.

相关标签:
2条回答
  • 2020-11-30 02:34

    You can access referer with

    request.referer
    
    0 讨论(0)
  • 2020-11-30 02:53

    request.referer returns a string, but you can use Ruby's URI Module to wrap it and then simply ask it for its path:

    if URI(request.referer).path == '/adsense'
    
    0 讨论(0)
提交回复
热议问题