2009/08/31

GOOGLEのCanonical URL

動的URLだと、ひとつの商品に付き複数のURLが発生します。
googleなどの検索エンジンのリスティングではNGらしいので
こういった場合の対策として
<link rel="canonical" href="登録したいURL" />

ってのを挟めば良いそうです。

なのでoscommerceに組み込んでみます。

../catalog/includes/function/general.phpの最後の行に

//Canonical URL対策はじまり
function CanonicalUrl() {
$domain = substr((($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER), 0, -1); // gets the base URL minus the trailing slash
$string = $_SERVER['REQUEST_URI']; // gets the url
$search = '\&osCsid.*|\?osCsid.*'; // searches for the session id in the url
$replace = ''; // replaces with nothing i.e. deletes
echo $domain . ereg_replace( $search, $replace, $string ); // merges the variables and echoing them
}
//Canonical URL対策おしまい
ってなくだりを入れて

動的URLになるページのヘッダーに(index.php,default.php,product_info.php)
これを挟み込む。
<link rel="canonical" href="<?php CanonicalUrl(); ?>" />

2009/08/24

Oscommerce引っ越し - Unable to determine the page link、Oscommerce

Error! Unable to determine the page link! が表示される

対策:管理画面の『サーチエンジン対策のURLを使用(開発中)』をoffにするか

../catalog/includes/apprication_top.phpの以下の件を変更。
だいたい185行目付近
$PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF);
バージョンが違えば
$PHP_SELF = str_replace(getenv('PATH_INFO'), '', $HTTP_SERVER_VARS['PHP_SELF']);
これを
こう変更する。
$PHP_SELF = str_replace(getenv('PATH_INFO'), '', $_SERVER['SCRIPT_FILENAME']);

2009/08/20

Got error 28 from table handler

Got error 28 from table handler

見慣れないエラーが出ている。
ここ数日はサーバーのファイルに触れていないので
データベースがどうにかなったのかな?

とりあえずテーブルの最適化をして様子をみます。