Forum Moderators: phranque
I saw that this had been discussed before, but I was looking for an example to use.
I have a site and my name is the same as an "adult" actress and a cricket player. When someone googles the name, a lot of people get to my site.
I'd like to use that search string from the referrer to send just those people to another page that tells them I'm not the actress or the cricket player. :)
How would I craft a rewrite so that it looks for the words "<actress name> adult" in the referrer? I've tried a few times on my own, and my efforts have caused my site not to load.
Thanks in advance!
Beth
[edited by: jdMorgan at 4:27 pm (utc) on Dec. 18, 2007]
[edit reason] Removed specifics per Terms of Service [/edit]
The best solution would be to modify your page and/or page title with a difference that would separate your website from these other websites?
Even with the SERP of "Beth's", your page still returns in the 9th result.
However, many webmasters would pay dearly to have endless traffic directed to their sites offering potential traffic otherwise not possible.
It's the custom of this forum for the inquiry to provide a "best effort" for others to assist (see forum charter).
Since I'm NOT however providing what you asked for, rather a denial (as opposed to a redirect), I've abused a
loop-hole ;)
the following simply denies access based on the word being contained anywhere in the UA.
RewriteCond %{HTTP_USER_AGENT} porn
RewriteRule .* - [F]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_REFERRER} beth+morgan+porn [NC,OR]
RewriteCond %{HTTP_REFERRER} beth+morgan+cricket [NC]
RewriteRule .* - [F]
The solution you're asking about is relatively simple -- But it will save us a lot of time if we have an example upon which to base discussion, as the example will illustrate where we need to focus effort toward corrections and explanations.
Wilderness brings up a good point: There are several search terms you'll probably want to redirect, not just the main one that identifies the traffic sector.
Thanks,
Jim
RewriteCond %{HTTP_REFERER} [?+&]?beth[?+&]? [NC]
RewriteCond %{HTTP_REFERER} [?+&]?(cricket¦adult¦porno?)[?+&]? [NC]
RewriteCond %{REQUEST_URI} !^alternate_page\.html$
RewriteCond %{REQUEST_URI} !^([^/]+/)*[^/.]+\.[^/.]+$
RewriteRule .* http://www.example.com/alternate_page.html [R=302,L]
Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Jim
[edit]Corrected as noted below. [/edit]
[edited by: jdMorgan at 10:49 pm (utc) on Dec. 18, 2007]
I thought the Wordpress might be causing something and moved it as you suggested. Ok, here's what I have now (below). I put in some really obvious stuff to test with and then went to google to search on "beth myeloma blog velcade." I see some posts from my blog there and click, but am not sent to cnn.com (just there to test with so it's something obviously different).
I did change the pipe symbols too.
RewriteCond %{HTTP_REFERRER} [?+&]?beth[?+&]? [NC]
RewriteCond %{HTTP_REFERRER} [?+&]?(myeloma¦velcade¦blog?)[?+&]? [NC]
RewriteCond %{REQUEST_URI}!^alternate_page\.html$
RewriteCond %{REQUEST_URI}!^([^/]+/)*[^/.]+\.[^/.]+$
RewriteRule .* [cnn.com...] [R=302,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress