Forum Topic: tricky redirect

Forum: .htaccess Forum : General • Posted by RememberToForget • Updated:

There is this referer site with a broken/invalid link that keeps sending me traffic, and they inevitably get 404’ed. Contacting them about it has produced nothing. :)

This one particular broken link really eludes me, I keep trying various methods and nothing seems to work. I’m wondering if it’s because of the link’s structure and/or location:

Location (or Referer):

The link they’re using to send traffic to my site:

Rather than show you the 50 things I’ve tried so far I guess I’ll just ask how would you handle this one.

Optimally I’d like all traffic coming from go to the location

My second choice would be for a Redirect of some kind, as in:

I’m using this one now and it works, however, it’s not enough:

RedirectMatch 302 /problem/?$

And this, for some reason, does not work at all (redirect loop error):

Redirect 302 /problem/index.php

(I feel strange, it’s not in my nature to ask people for help. Is there a paypal address where I can send you a tip?)

2 Replies to “tricky redirect”

Posted by Jeff Starr

Here are two methods that should do it, first I would try just blocking the bad referrer entirely:

<IfModule mod_rewrite.c>
	RewriteCond %{HTTP_REFERER} badsite\.com  [NC,OR]
	RewriteRule .* - [F,L]

And if that was not suitable, say I want to keep some of the referral traffic, then I would get specific and block the problem request:

<IfModule mod_rewrite.c>
	RewriteCond %{REQUEST_URI} ^/problem/index.php
	RewriteCond %{QUERY_STRING} option=content&task=view&id=75
	RewriteRule .* - [F,L]

Of course, these will require testing and possible fine-tuning according to your existing configuration, rules, etc.

Posted by RememberToForget •

OK, I finally got to the bottom of why my htaccess directives were working so inconsistently. I emailed my hosting guy, and he’s one of these command line wizards that knows “everything about everything” and he told me to turn off Chrome caching and suddenly everything just works.

I would never have guessed that this could have been the case, and frankly I was just about to give up on my goal of getting my htaccess issues in order.

Anyway thanks for everything, I’ll probably flourish with your book now that this oddity has been cleared up.