Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get referrer from a redirected url

I have an url

domain.com/a

which redirects to

domain.com/controller/action/a .

How do I get the referrer (i.e domain.com/a) in my action for domain.com/controller/action/a ?

One option was to add the referring domain as a parameter .

domain.com/controller/action/a?referral=domain.com/a .

Is there a way to get the referrer without passing old referrer as a parameter. Like we would get from **request.referrer**. request.referrer doesn't seem to work with redirected urls.

I am using Ruby on Rails for my development.

like image 542
Prabesh Shrestha Avatar asked Jan 17 '12 17:01

Prabesh Shrestha


People also ask

How do I find the URL referrer?

To check the Referer in action go to Inspect Element -> Network check the request header for Referer like below. Referer header is highlighted. Supported Browsers: The browsers are compatible with HTTP header Referer are listed below: Google Chrome.

What is URL referrer?

The address of the webpage where a person clicked a link that sent them to your page. The referrer is the webpage that sends visitors to your site using a link. In other words, it's the webpage that a person was on right before they landed on your page.

Do all browsers send referrer?

Some web browsers give their users the option to turn off referrer fields in the request header. Most web browsers do not send the referrer field when they are instructed to redirect using the "Refresh" field. This does not include some versions of Opera and many mobile web browsers.

What is a referer in HTTP request?

The Referer HTTP request header contains an absolute or partial address of the page that makes the request. The Referer header allows a server to identify a page where people are visiting it from. This data can be used for analytics, logging, optimized caching, and more.


1 Answers

I store the referrer path in the session right before redirection

session[:referrer]=url_for(params)

and then use it where I need it via session[:referrer].

like image 92
okliv Avatar answered Sep 22 '22 13:09

okliv