View Single Post
Old 04-01-2009, 11:06 PM   #7 (permalink)
WebSavvy
The Contributor
 
WebSavvy's Avatar
 
Join Date: Mar 2009
Location: Springfield, IL USA
Posts: 75
Thanks: 3
WebSavvy is on a distinguished road
Default

Yep, it's always better to err on the side of safety whenever possible.

What is it exactly, that you're trying to do, and why? What I mean is, are you trying to avoid linking to bad neighborhoods or is it that you're just wishing to keep an open active area for the visitor to "stay on your site" Vs leaving and going to another site?

If you're wishing to keep an open active area for the visitor to not completely leave your site, you can always open external links in a new window.

If you're looking to avoid linking to bad neighborhoods you can always add nofollow to the external link or use a redirect.

However, if using a redirect you'd need to make sure that your script sends a 301 header and not a 302 header. If it sends a 302 then there's every possibility your "script" may pull off a 302 hijacking.

The easiest way to avoid that is, create a small db and add 2 fields to the table. One field for ID (make it primary, auto_increment, unique) and then add one for urls (varchar 255).

Create a small php script that will pull the IDs & urls from your table based on the script parameter (e.g., redirect.php?site=bbc.co.uk -- the "site" parameter would give the url to be pulled from the table).

Once the url is pulled from the table, add a php redirect (301) to the code in the redirect script and it'll automatically forward the visitor to that url.

The reason you want to have control of it with a db is the fact that spammers would abuse your redirect script and make it appear that you're linking to things you are not. How they accomplish that is by linking to your redirect script with some other site url attached, and they'd be able to do it from their own sites.

If you're considering a redirect script and aren't sure how to create one, just let me know and I'll post the codes for you here. I've written and used them 100s of times myself.

hope this helps.
WebSavvy is offline  
Reply With Quote
The Following User Says Thank You to WebSavvy For This Useful Post:
Brook (04-02-2009)