Welcome to WebmasterWorld Guest from 107.21.159.218

Forum Moderators: open

Message Too Old, No Replies

JavaScript redirect based on part of referrer URL

trying to divert visitors who have been given wrong URL

     

RedTCat

11:44 pm on Feb 1, 2008 (gmt 0)

5+ Year Member



A very well known web site has many pages containing links to my web site. The links were accidentally posted - instead of links to a web site belonging to a user of that site. I have contacted the user who does not seem interested. I have contacted the site but they will not act on complaints concerning a "member", only complaints about specific posts by a member. I can't send a complaint for every page (new ones every day) posted by the user.

The links are only and always to the same page on my site, I can't use PHP (as the destination *has* to be the existing page url: page.HTML) can anyone suggest a piece of JavaScript I can put on the page that will detect part of the referrer url (might be subdomain.example.com or cgi.example.co.uk, so I need to check for "example" only) that will redirect these visitors to a page explaining they've been mis-directed.

Many thanks in advance.
LG

mehh

5:14 pm on Feb 2, 2008 (gmt 0)

5+ Year Member



if you are using an apache webserver .htaccess may be a better answer [google.com]. But I don't understand, not that it is any of my bussiness, why are the extra visitors a problem?

RedTCat

6:11 pm on Feb 2, 2008 (gmt 0)

5+ Year Member



Thanks but htaccess is going to be too technical for me ...

As they don't *want* to visit my site, they're just unlucky enough to click a link that's nothing to do with the site they are on, nor the text in the link itself. (and they are skewing my stats)

I've had abusive emails from people thinking *I'm* responsible...

mehh

1:28 pm on Feb 3, 2008 (gmt 0)

5+ Year Member



fair enough. javascript is a poor option for this though as some people will be veiwing the web without it. Thats why I recommended .htaccess. I suppose you could use javascript if you *really* wanted to though. something like this
if((/^https?\:\/\/(www\.)?example\.com/).test(document.referrer)){
location.href="anotherpage.html";
}

rocknbil

4:12 pm on Feb 3, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The links are only and always to the same page on my site

A greater problem here is how this will affect the PR for your incoming links. JS won't help that, SE's will still get a 404.

.htaccess is no more complicated than Javascript, but there's an easier solution - why don't you just create a variation of the page with a link to "original article?" You want it to be a variation so you don't get a duplicate content problem.

RedTCat

7:01 pm on Feb 3, 2008 (gmt 0)

5+ Year Member



Thanks mehh and rocknbil,

Not too fussed about some people not using JS seeing the normal page - but most would get redirected.

Unfortuntely the page in question is the site home page...

They won't get a 404 'cos the page does exist... I had not thought about page rank, I am using Google Webmaster Tools and have not yet seen the link text in the "What Googlebot sees" statstics.

I've now implimentd a bit of JS simialr to that suggested by mehh, which gives people from *that* domain a polite but clear message that they've been "mis-directed"

Thanks
LG

 

Featured Threads

Hot Threads This Week

Hot Threads This Month