jcreamer898
jcreamer898

Reputation: 8189

Mock the CGI.HTTP_REFERER using Coldfusion

I am trying to write some search engine optimized code for a Coldfusion project, and one thing I am trying to accomplish in that is changing a few page variables when the page is referred from different search engines.

Does anyone know if there is a way, or if it's even possible to mock the CGI.HTTP_REFERER to Google, Bing, Yahoo, etc??

Upvotes: 1

Views: 4895

Answers (4)

Henry
Henry

Reputation: 32915

Refactor your method, instead of using CGI scope directly, use an argument, e.g.:

<cfargument name="cgiScope" type="struct" default="#CGI#" require="false">

Done. :)

Upvotes: 2

Aaron Silverman
Aaron Silverman

Reputation: 22645

I would make a function getHttpReferer that normally returns CGI.HTTP_REFERER, however when you unit test you can mock out that function to return whatever you want.

Upvotes: 0

orangepips
orangepips

Reputation: 9971

The value of the CGI scope is large in part determined by what's sent in a request's headers. The referer in particular is easily spoofed. See the following:

  1. Ben Nadel explains how to with CFHTTP and CFHTTPPARAM to spoof the referer.
  2. Firefox Plugin Modify Headers (my comment points an answer with this).

Upvotes: 0

eapen
eapen

Reputation: 579

It is frowned upon to show different kind of content for search engine bots. Either way, it is not possible to change the CGI.HTTP_REFERER with Coldfusion. Your best bet is to edit your "hosts" file and add an entry to point google.com to the IP of your server (eg. 127.0.0.1) and set up a page with a link to your site to fake the request as coming from Google/Bing/Yahoo.

Upvotes: 0

Related Questions