homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

JavaScript redirect based on part of referrer URL
trying to divert visitors who have been given wrong URL

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

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.



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

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?


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

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...


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

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


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

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.


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

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"


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved