如何获取请求引用程序路径?

我需要引用者的路径。我不想要域名。例如,如果引用者是 我要 /adsense

84397 次浏览

You can access referer with

request.referer

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'