マイクロ office ★excel2016 価格 http://www.msofisu.com

microsoft オフィス ★office365 価格 個人

Eccube URL静的化完全版 商品詳細ページURL カテゴリURL最適化

EC-CUBEの静的URL生成 URL静的化完全版 商品詳細ページURL カテゴリURL最適化

EC-CUBE 2.13://URL静的化完全版 商品詳細ページURL カテゴリURL最適化 EC-CUBEのデフォルトは動的URLで作成されます,これを静的URLに変更してSEO 対策します。

URLを設計する際の推奨ポイント SEO

URLを永続化させるためには、設計時から長く使えて検索エンジンが好むURLを設計しておくことが重要です。以下にポイントをまとめておきますので、設計時の参考にしてください。

URLに使用していい推奨記号は、「-(ハイフン)」と「_(アンダースコア)」 URLはすべて小文字にする URLの長さはなるべく短くしつつ、可能であればURL中にキーワードを含める ディレクトリの階層はなるべく浅くする 永続性さえ確保できれば、日本語URLも効果がある 番外. URLは拡張子ではなく、「/」で終える

EC-CUBE 2.13://URL静的化完全版を目指す

EC-CUBEで構築したサイトは商品カテゴリ一覧ページや商品詳細ページのURLが、 「http://サーバ名/products/list.php?category_id=xxx」 「http://サーバ名/products/detail.php?product_id=xxx」 という様に、「~.php?~」とURLにクエリが付けてられている状態になります。

最近のGoogleはクエリ付きURLでも先のページをちゃんとクロールしてくれるという話しですが、 過去のSEOを知る身として、そしてURLがクエリ丸見え状態というのはちょっと恥ずかしさもあります。

何より、SEO対策というのは、どれが本当に効果が表れるかというのはとても分かりずらいものなので、 些細なことでも対策しておいて損は無いということもあり、URLの静的化はやっておいて損は無いでしょう。

何より、サイトのURLが美しくて良いです。 

EC-CUBEのURL静的化の現状

Googleなどで検索するればそれらしい記事はたくさん出てきますが、 RSSやsitemap、プラグイン関係まで言及している記事が無かったので、 いきなり完全版にはならないかも知れませんが、一歩一歩進化させていこうと思います。

まず、静的化後のURLをどうするかですが、これも幾つか考えられます。

例えば、

  • http://サーバ名/products/list123/
  • http://サーバ名/products/list/123
  • http://サーバ名/products/list123.html

と言った感じです。

これもSEO的には、ディレクトリが深くない方が良いとか、拡張子が付いていた方が良いなど諸説ありました。 現状としては、SEO的にはどれも変わりは無く、人が見たときにどう感じるかというレベルのようです。

では、「人が見たときに」とは何を考慮すべきか。 URLを見て何のページか分かりやすく、短く、ファイルの中身が何かわかりやすいことだと思います。

したがって、「http://サーバ名/products/list123.html」が一番妥当だと思われます。 

具体的な施策手順

1~2は、最近のサーバーであれば設定する必要が無いものが多いはずです。 今の時代に、mod_rewriteやhtaccessが使えないサーバーであれば、移転を検討すべきでしょう。

1. mod_rewriteの有効化

まずは、「mod_rewrite」を使ったURLリライトの設定を行います。 Webサーバー(Apache)でmod_rewriteが有効になっているかを調べましょう。 httpd.confに下記設定がなされているか、もしくはサーバー会社に問い合わせましょう。 LoadModule rewrite_module modules/mod_rewrite.so[/cod]

2 .htaccessの有効化

WEBサーバーの公開フォルダに対し、「.htaccess」の有効にします。 httpd.confに下記設定を行ってください。 1 <‎Directory “http公開フォルダのパス”>   AllowOverride All   Options FollowSymLinks <‎/Directory>

3. .htaccessにリライトを設定

EC-CUBEの公開ディレクトリルートの「.htaccess」に下記を追記してください。

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^products/detail([0-9]+).html products/detail.php?product_id=$1&%{QUERY_STRING} [L] RewriteRule ^products/list([0-9]+).html products/list.php?category_id=$1&%{QUERY_STRING} [L]

4. カテゴリーブロックテンプレートの修正

「/data/Smarty/template/default/bloc/category_tree_fork.tpl」を下記のように修正します。 27行目: <p><a href=“<!–{$smarty.const.ROOT_URLPATH}–>products/list.php?category_id=<!–{$child.category_id}–>"~ ↓

27行目: <p><a href=“<!–{$smarty.const.ROOT_URLPATH}–>products/list<!–{$child.category_id}–>.html"~

5. 商品詳細ページURLを示すパラメータ設定の変更

管理画面の「システム設定」→「パラメーター設定」を開き、 「P_DETAIL_URLPATH」という項目を下記のように変更します。

ROOT_URLPATH . “products/detail.php?product_id=”[/cod] ↓ 1ROOT_URLPATH . “products/detail”[/cod]

6. おすすめ商品ブロックテンプレートの修正

「/data/Smarty/template/default/bloc/recommend.tpl」を下記のように修正します。 1 32行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>”> 38行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>”>~ ↓ 32行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>.html”> 38行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>.html”>~

7. 商品一覧テンプレートの修正

「/data/Smarty/template/default/products/list.tpl」を下記のように修正します。 152行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>”> 171行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>”>~ 193行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>”>~ ↓ 152行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>.html”> 171行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>.html”>~ 193行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrProduct.product_id|u}–>.html”>~

8. 商品詳細テンプレートの修正

「/data/Smarty/template/default/products/detail.tpl」を下記のように修正します。 172行目: <a href=“<!–{$smarty.const.ROOT_URLPATH}–>products/list.php?category_id=<!–{$arrRelativeCat[r][s].category_id}–>”>~ 355行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrItem.product_id|u}–>”> 361行目: <h3><a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrItem.product_id|u}–>”>~ ↓ 172行目: <a href=“<!–{$smarty.const.ROOT_URLPATH}–>products/list<!–{$arrRelativeCat[r][s].category_id}–>.html”>~ 355行目: <a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrItem.product_id|u}–>.html”> 361行目: <h3><a href=“<!–{$smarty.const.P_DETAIL_URLPATH}–><!–{$arrItem.product_id|u}–>.html”>~

9. RSSテンプレートの修正

「/data/Smarty/template/default/rss/products.tpl」を下記のように修正します。 33行目: <link><!–{$smarty.const.HTTP_URL}–>products/detail.php?product_id=<!–{$arrProduct.product_id}–></link> 36行目: <a href=“<!–{$smarty.const.HTTP_URL}–>products/detail.php?product_id=<!–{$arrProduct.product_id}–>” rel=“product”> 39行目: <div class=“product-title”><a href=“<!–{$smarty.const.HTTP_URL}–>products/detail.php?product_id=<!–{$arrProduct.product_id}–>” rel=“product”>~ ↓ 33行目: <link><!–{$smarty.const.HTTP_URL}–>products/detail<!–{$arrProduct.product_id}–>.html</link> 36行目: <a href=“<!–{$smarty.const.HTTP_URL}–>products/detail<!–{$arrProduct.product_id}–>.html” rel=“product”> 39行目: <div class=“product-title”><a href=“<!–{$smarty.const.HTTP_URL}–>products/detail<!–{$arrProduct.product_id}–>.html” rel=“product”>~

10. sitemap.phpの修正

「/data/class_extends/page_extends/LC_page_Sitemap_Ex.php」に下記追記します。

function process() { parent::process(); } } ↓ function process() { parent::process(); }

/* * 全ての商品一覧ページを取得する. * * @return array 検索エンジンからアクセス可能な商品一覧ページの情報 / public function getAllProducts() { // XXX: 商品登録の無いカテゴリは除外する方が良い気もする $objQuery = SC_Query_Ex::getSingletonInstance(); $sql = ‘SELECT category_id FROM dtb_category WHERE del_flg = 0’; $result = $objQuery->getAll($sql);

$arrRet = array(); foreach ($result as $row) { // :TODO: カテゴリの最終更新日を取得できるようにする

$arrPage[‘url’] = HTTP_URL . ‘products/list’ . $row[‘category_id’] . “.html”; $arrRet = $arrPage; }

return $arrRet; }

/* * 全ての商品詳細ページを取得する. * * @return array 検索エンジンからアクセス可能な商品詳細ページの情報 / public function getAllDetail() { $objQuery = SC_Query_Ex::getSingletonInstance(); $sql = ‘SELECT product_id, update_date FROM dtb_products WHERE ’ . SC_Product_Ex::getProductDispConditions(); $result = $objQuery->getAll($sql);

$arrRet = array(); foreach ($result as $row) { $arrPage[‘update_date’] = $row[‘update_date’];

$arrPage[‘url’] = HTTP_URL . substr(P_DETAIL_URLPATH, strlen(ROOT_URLPATH)) . $row[‘product_id’] . “.html”; $arrRet = $arrPage; }

return $arrRet; } }

あとは、マイページ、お気に入り、スマホ・フューチャーフォンの対策も必要になるかと思いますが。

(4)以下のPC用ファイルに「.html」を追記する。 ■data/Smarty/templates/default/products/list.tpl(3カ所) ■data/Smarty/templates/default/frontparts/bloc/recommend.tpl(2カ所) <!–{$arrProduct.product_id|u}–> ↓(変更) <!–{$arrProduct.product_id|u}–><!–{if $smarty.const.STATIC_URL == true}–>.html<!–{/if}–> ■data/Smarty/templates/default/products/detail.tpl(「関連商品」の2カ所) <!–{$arrItem.product_id|u}–> ↓(変更) <!–{$arrItem.product_id|u}–><!–{if $smarty.const.STATIC_URL == true}–>.html<!–{/if}–> (5)スマートフォン用ファイルに「.html」を追記する。 ■data/Smarty/templates/sphone/products/list.tpl(1カ所) <!–{$arrProduct.product_id|u}–> ↓(変更) <!–{$arrProduct.product_id|u}–><!–{if $smarty.const.STATIC_URL == true}–>.html<!–{/if}–> ■data/Smarty/templates/sphone/frontparts/bloc/recommend.tpl(1カ所) <!–{$arrBestProducts[cnt].product_id|u}–> ↓(変更) <!–{$arrBestProducts[cnt].product_id|u}–><!–{if $smarty.const.STATIC_URL == true}–>.html<!–{/if}–> ■data/Smarty/templates/sphone/products/detail.tpl(「その他おすすめ商品」の1カ所) <!–{$arrRecommend[cnt].product_id|u}–> ↓(変更) <!–{$arrRecommend[cnt].product_id|u}–><!–{if $smarty.const.STATIC_URL == true}–>.html<!–{/if}–> (6)MYページのhistory.tpl,favorite.tplに適用 ■data/Smarty/templates/default/mypage/history.tpl(1カ所) ■data/Smarty/templates/sphone/mypage/history.tpl(1カ所) <!–{$orderDetail.product_id|u}–> ↓(変更) <!–{$orderDetail.product_id|u}–><!–{if $smarty.const.STATIC_URL == true}–>.html<!–{/if}–> ■data/Smarty/templates/default/mypage/favorite.tpl(2カ所) ■data/Smarty/templates/sphone/mypage/favorite.tpl(2カ所) <!–{$product_id|u}–> ↓(変更) <!–{$product_id|u}–><!–{if $smarty.const.STATIC_URL == true}–>.html<!–{/if}–>