1

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??

ale
  • 6,369
  • 7
  • 55
  • 65
jcreamer898
  • 8,109
  • 5
  • 41
  • 56

4 Answers4

2

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

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

Done. :)

David Faber
  • 12,277
  • 2
  • 29
  • 40
Henry
  • 32,689
  • 19
  • 120
  • 221
0

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.

eapen
  • 579
  • 6
  • 15
0

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).
orangepips
  • 9,891
  • 6
  • 33
  • 57
0

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.

Aaron Silverman
  • 22,070
  • 21
  • 83
  • 103