Tuesday, June 13, 2006

Facilitating a Search Engine in Spidering a Popup

From the previous post, it becomes clear that a search engine may spider a page only refered to via javascript; but what if want just the opposite -- you explicitly want it to be indexed?

It's pretty simple; change this:
<a href="javascript:myPopupFunction()" html="">Click here.</a>
To This:
<a href="page.html" onclick="javascript:myPopupFunction(this.href); return false;">Click here.</a>
Alternatively, you can link using something like this:
<a href="page.html">Click here.</a>
And then use Javascript included on that page that is automatically run to resize the window. Technically, it's not a popup. It's a new window that automatically resizes, but the effect is similar.

It is worth noting that since these pages will be indexed, some sort of navigation should be present to allow the user to get back to the parent page. Otherwise the user will be completely lost and proceed to the back button.

Don't Count on Javascript Links

This may be common sense, but javascript links shouldn't be used as a sort of third exclusion protocol. This is for 2 reasons.

1) People still could theoretically look at the properties on the page, grab the URL, and link it externally. This may result in the page getting indexed.

2) It is been reported that Google at least does, in fact, index links embedded in javascript sometimes, or at least understand them for the purposes of spam detection.

The bottom line: Make sure that you also exclude the popup URL in robots.txt, or exclude it using meta exclusions.

Thursday, June 08, 2006

Using Redirects to Change File Names

The following is a simple way to redirect a page A to a page B with a few lines.

In .htaccess using mod_rewrite:
RewriteEngine on
RewriteRule ^foo\.php$ bar.php [R=301,L]

In PHP (place in foo.php):
$base_url = 'http://www.foo.com';
header('Location: ' . $base_url . 'bar.php';

Hope this helps!