can I block and redirect url shortener

espressox

Registered Member
Joined
Apr 24, 2011
Messages
75
Reaction score
7
I have a lot of traffic coming from a url shortener like bit.ly but I would like to stop the traffic hitting my site and redirect it out to another site.
I know PHP and JS redirects but I want to stop the traffic showing in my analytics or my hosting account in the first place. Is there away to do this either with a script or with google analytics
 
Can I redirect it instead of blocking it
 
I did set up a 301 but what I was trying to do was just stop a link https://www.bit.ly/xxx from redirecting to my site but going some where else instead a 301 would work too.
Am I right in saying a 301 blocks the traffic so my host wont see it or it wont be counted
 
Ah I gotcha now. No if it hits your site, your host will be able to see it in the logs.

I can only think of 2 ways you could prevent it from hitting your site, and prevent it being able to be logged by apache/nginx.

1.) A DNS change

2.) If you had server level control and could block it at the network level. i.e. firewall. But it doesn't sound like you have that level of control
 
Code:
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], '/bit.ly/') !== false) {
    header("Location: https://www.google.com/");
    exit;
}
 
That's still going to hit his site though.

He never wants the host to see the request hit his site.

That code redirects after the request has already hit the server.
 
Can you tell us about your site? Maybe I have been using it as a safe page lol. I am serious though... Tell us.
 
In CPanel, will not "IP Blocker" block all the requests from specific IP's and websites?
Never used it so not sure, just know that there's such an option.
 
I don't use cpanel, so I'm not familiar with that option.

But if it does what it sounds like it does, then I think that's going to be about as good as it's gonna get for you OP.
 
Back
Top