Forum Moderators: open
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
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...
if((/^https?\:\/\/(www\.)?example\.com/).test(document.referrer)){
location.href="anotherpage.html";
}
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.
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