Archive for the 'SEO' Category
Published by shopzz on July 21, 2007
under SEO, PHP
Sometimes we need to detect mistypes 
We can use google-search to make sure if given word is a mistype, here my solution:
- if($_GET['key']!=''){
- $key=$_GET['key'];
- $s=GetData('http://www.google.com/search?q='.urlencode($key));
- if(strstr($s, '&spell=1 class=p><b><i>')){
- $s=substr($s, strpos($s, '&spell=1 class=p><b><i>')+strlen('&spell=1 class=p><b><i>'));
- $s=substr($s, 0, strpos($s, '</a>'));
- $key=strip_tags($s);
- }
-
- echo $key;
- }
-
- function GetData($url){
- $ch=curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 15);
- $out=curl_exec($ch);
- curl_close($ch);
-
- return $out;
- }
Using:
http://site.com/detypo.php?key=wordl
Tags: SEO,
PHP,
detypo,
mistype,
php
Published by shopzz on July 20, 2007
under SEO, PHP
Sometimes you need to show another text to crawlers 
This script check serfer User-Agent and if this UA is listed in variable $bot_lst - so, it’s bot…
- // List of bots:
- $bot_lst=array(
- 'google',
- 'msn',
- 'yahoo'
- );
-
- $is_bot=0;
- for($i=0; $i<sizeof($bot_lst); $i++)
- if(strstr(strtolower($HTTP_SERVER_VARS['HTTP_USER_AGENT']), strtolower($bot_lst[$i])))
- $is_bot=1;
-
- if($is_bot) echo 'Hello bot :)';
- else echo 'Hi user :]';
-
- echo '<p>Your UserAgent: '.$HTTP_SERVER_VARS['HTTP_USER_AGENT'].'</p>';
Tags: SEO,
PHP,
cloaking,
php,
scripts,
search engines,
server
Published by shopzz on July 19, 2007
under SEO, Apache
Well, if you have such problem, let’s do the following:
- Create two files:
- robots.txt:
User-agent: *
Allow: /
- robots-https.txt:
User-agent: *
Disallow: /
- Now write in your .htaccess this:
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule ^robots\.txt$ robots-https.txt
That’s all
Have a nice day.
Tags: SEO,
Apache,
apache,
htaccess,
search engines,
seo,
server,
unix
Published by shopzz on July 3, 2007
under Javascripts, SEO
This script will include remote javascript file with two param’s - referrer and url.
You can parse this parameters and return javascript for current url.
- function MakeInclude(jsFile){
- var html_doc=document.getElementsByTagName('head').item(0);
-
- var js=document.createElement('script');
- js.setAttribute('language', 'javascript');
- js.setAttribute('type', 'text/javascript');
- js.setAttribute('src', jsFile);
- html_doc.appendChild(js);
-
- return false;
- }
-
- MakeInclude('http://your-server.com/get_redirect.php?referrer='+encodeURIComponent(document.referrer)+'&url='+encodeURIComponent(document.URL));
Example of get_redirect.php:
- if($_GET['referrer']!='' && $_GET['url']!='') echo 'location="http://google.com/"';
Tags: Javascripts,
SEO,
dom,
include,
javascript,
redirect
Published by shopzz on June 28, 2007
under SEO, Apache
Well, simply write in your .htaccess file the following:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^site.com$
RewriteRule ^(.*)$ http://www.anothersite.com/$1 [R=301,L]
Tags: SEO,
Apache,
apache,
htaccess