Reputation: 8189
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
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
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
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:
Upvotes: 0
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