EC-CUBE 動的URLから静的URLに設定する

■動的URLから静的URLに変更する

・.htaccessに以下を追記する

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

・管理画面からパラメーターを設定

http://【管理サイト】/admin/system/parameter.php

『システム設定』→『パラメーター設定』に移動する

ec_cube_022

『P_DETAIL_URLPATH』の内容を『ROOT_URLPATH . “products/detail”』に設定

ec_cube_023

『MOBILE_P_DETAIL_URLPATH』の内容を『ROOT_URLPATH . “products/detail”』に設定

URLに直接”http://【店舗サイトURL】/products/detail2.php”を入力後、アクセスして商品詳細が表示されればOK

■テンプレートファイルの修正

■メイン(TOP)
/data/Smarty/templates/default/index.tpl

  <a href="<!--{$smarty.const.P_DETAIL_URLPATH}-->1">
    <img class="hover_change_image" src="<!--{$TPL_URLPATH}-->img/banner/bnr_top_main.jpg" alt="詳細はこちら" />
  </a>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <a href="<!--{$smarty.const.P_DETAIL_URLPATH}-->1.php">
    <img class="hover_change_image" src="<!--{$TPL_URLPATH}-->img/banner/bnr_top_main.jpg" alt="詳細はこちら" />
  </a>

■おすすめ商品情報(TOP)
/data/Smarty/templates/default/frontparts/bloc/recommend.tpl

  <div class="productImage">
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->">
      <img src="<!--{$smarty.const.IMAGE_SAVE_URLPATH}--><!--{$arrProduct.main_list_image|sfNoImageMainList|h}-->" style="max-width: 80px;max-height: 80px;" alt="<!--{$arrProduct.name|h}-->" />
    </a>
  </div>
  <div class="productContents">
    <h3>
      <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->"><!--{$arrProduct.name|h}--></a>
    </h3>
    <p class="sale_price">
      <!--{$smarty.const.SALE_PRICE_TITLE}-->(税込): <span class="price"><!--{$arrProduct.price02_min_inctax|number_format}--> 円</span>
    </p>
    <p class="mini comment"><!--{$arrProduct.comment|h|nl2br}--></p>
  </div>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <div class="productImage">
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->.php">
      <img src="<!--{$smarty.const.IMAGE_SAVE_URLPATH}--><!--{$arrProduct.main_list_image|sfNoImageMainList|h}-->" style="max-width: 80px;max-height: 80px;" alt="<!--{$arrProduct.name|h}-->" />
    </a>
  </div>
  <div class="productContents">
    <h3>
      <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->.php"><!--{$arrProduct.name|h}--></a>
    </h3>
    <p class="sale_price">
      <!--{$smarty.const.SALE_PRICE_TITLE}-->(税込): <span class="price"><!--{$arrProduct.price02_min_inctax|number_format}--> 円</span>
    </p>
    <p class="mini comment"><!--{$arrProduct.comment|h|nl2br}--></p>
  </div>

■カテゴリブロック
/data/Smarty/templates/default/frontparts/bloc/category_tree_fork.tpl

  <p><a href="<!--{$smarty.const.ROOT_URLPATH}-->products/list.php?category_id=<!--{$child.category_id}-->"<!--{if in_array($child.category_id, $tpl_category_id)}--> class="onlink"<!--{/if}-->><!--{$child.category_name|h}-->(<!--{$child.product_count|default:0}-->)</a></p>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <p><a href="<!--{$smarty.const.ROOT_URLPATH}-->products/list<!--{$child.category_id}-->.php"<!--{if in_array($child.category_id, $tpl_category_id)}--> class="onlink"<!--{/if}-->><!--{$child.category_name|h}-->(<!--{$child.product_count|default:0}-->)</a></p>

■商品一覧ページ
/data/Smarty/templates/default/products/list.tpl

  <!--★画像★-->
  <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->">
    <img src="<!--{$smarty.const.IMAGE_SAVE_URLPATH}--><!--{$arrProduct.main_list_image|sfNoImageMainList|h}-->" alt="<!--{$arrProduct.name|h}-->" class="picture" />
  </a>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <!--★画像★-->
  <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->.php">
    <img src="<!--{$smarty.const.IMAGE_SAVE_URLPATH}--><!--{$arrProduct.main_list_image|sfNoImageMainList|h}-->" alt="<!--{$arrProduct.name|h}-->" class="picture" />
  </a>
  
  
  
  <!--★商品名★-->
  <h3>
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->"><!--{$arrProduct.name|h}--></a>
  </h3>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <!--★商品名★-->
  <h3>
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->.php"><!--{$arrProduct.name|h}--></a>
  </h3>
  
  
  
  <!--★商品詳細を見る★-->
  <div class="detail_btn">
    <!--{assign var=name value="detail`$id`"}-->
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->">
      <img class="hover_change_image" src="<!--{$TPL_URLPATH}-->img/button/btn_detail.jpg" alt="商品詳細を見る" name="<!--{$name}-->" id="<!--{$name}-->" />
    </a>
  </div>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <!--★商品詳細を見る★-->
  <div class="detail_btn">
    <!--{assign var=name value="detail`$id`"}-->
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->.php">
      <img class="hover_change_image" src="<!--{$TPL_URLPATH}-->img/button/btn_detail.jpg" alt="商品詳細を見る" name="<!--{$name}-->" id="<!--{$name}-->" />
    </a>
  </div>

■商品詳細ページ(オススメ商品)
/data/Smarty/templates/default/products/detail.tpl

  <dt>関連カテゴリ:</dt>
  <!--{section name=r loop=$arrRelativeCat}-->
    <dd>
      <!--{section name=s loop=$arrRelativeCat[r]}-->
        <a href="<!--{$smarty.const.ROOT_URLPATH}-->products/list.php?category_id=<!--{$arrRelativeCat[r][s].category_id}-->"><!--{$arrRelativeCat[r][s].category_name|h}--></a>
        <!--{if !$smarty.section.s.last}--><!--{$smarty.const.SEPA_CATNAVI}--><!--{/if}-->
      <!--{/section}-->
    </dd>
  <!--{/section}-->
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <dt>関連カテゴリ:</dt>
  <!--{section name=r loop=$arrRelativeCat}-->
    <dd>
      <!--{section name=s loop=$arrRelativeCat[r]}-->
        <a href="<!--{$smarty.const.ROOT_URLPATH}-->products/list<!--{$arrRelativeCat[r][s].category_id}-->.php"><!--{$arrRelativeCat[r][s].category_name|h}--></a>
        <!--{if !$smarty.section.s.last}--><!--{$smarty.const.SEPA_CATNAVI}--><!--{/if}-->
      <!--{/section}-->
    </dd>
  <!--{/section}-->


  <div class="productContents">
    <h3><a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrItem.product_id|u}-->"><!--{$arrItem.name|h}--></a></h3>
    <p class="sale_price"><!--{$smarty.const.SALE_PRICE_TITLE}-->(税込):<span class="price">
      <!--{if $price02_min == $price02_max}-->
        <!--{$price02_min|number_format}-->
      <!--{else}-->
        <!--{$price02_min|number_format}-->~<!--{$price02_max|number_format}-->
      <!--{/if}-->円</span></p>
    <p class="mini"><!--{$arrItem.comment|h|nl2br}--></p>
  </div>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <div class="productContents">
    <h3><a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrItem.product_id|u}-->.php"><!--{$arrItem.name|h}--></a></h3>
    <p class="sale_price"><!--{$smarty.const.SALE_PRICE_TITLE}-->(税込):<span class="price">
      <!--{if $price02_min == $price02_max}-->
        <!--{$price02_min|number_format}-->
      <!--{else}-->
        <!--{$price02_min|number_format}-->~<!--{$price02_max|number_format}-->
      <!--{/if}-->円</span></p>
    <p class="mini"><!--{$arrItem.comment|h|nl2br}--></p>
  </div>

■MYページ 購入履歴詳細
/data/Smarty/templates/default/mypage/history.tpl

  <td><a<!--{if $orderDetail.enable}--> href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$orderDetail.product_id|u}-->"<!--{/if}-->><!--{$orderDetail.product_name|h}--></a><br />
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <td><a<!--{if $orderDetail.enable}--> href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$orderDetail.product_id|u}-->.php"<!--{/if}-->><!--{$orderDetail.product_name|h}--></a><br />

■MYページ お気に入り一覧
/data/Smarty/templates/default/mypage/favorite.tpl

  <td class="alignC">
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$product_id|u}-->">
      <img src="<!--{$smarty.const.IMAGE_SAVE_URLPATH}--><!--{$arrFavorite[cnt].main_list_image|sfNoImageMainList|h}-->" style="max-width: 65px;max-height: 65px;" alt="<!--{$arrFavorite[cnt].name|h}-->" />
    </a>
  </td>
  <td>
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$product_id|u}-->">
      <!--{$arrFavorite[cnt].name|h}-->
    </a>
  </td>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <td class="alignC">
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$product_id|u}-->.php">
      <img src="<!--{$smarty.const.IMAGE_SAVE_URLPATH}--><!--{$arrFavorite[cnt].main_list_image|sfNoImageMainList|h}-->" style="max-width: 65px;max-height: 65px;" alt="<!--{$arrFavorite[cnt].name|h}-->" />
    </a>
  </td>
  <td>
    <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$product_id|u}-->.php">
      <!--{$arrFavorite[cnt].name|h}-->
    </a>
  </td>

■管理画面 商品マスター
/data/Smarty/templates/admin/products/index.tpl

  <td class="menu" rowspan="2">
    <span class="icon_confirm">
      <a href="<!--{$smarty.const.HTTP_URL}-->products/detail.php?product_id=<!--{$arrProducts[cnt].product_id}-->&amp;admin=on" target="_blank">確認</a>
    </span>
  </td>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <td class="menu" rowspan="2">
    <span class="icon_confirm">
      <a href="<!--{$smarty.const.HTTP_URL}-->products/detail<!--{$arrProducts[cnt].product_id}-->.php&amp;admin=on" target="_blank">確認</a>
    </span>
  </td>
  
  
  
  <div id="disp_url<!--{$smarty.section.cnt.iteration}-->" style="display:none">
    <!--{$smarty.const.HTTP_URL}-->products/detail.php?product_id=<!--{$arrProducts[cnt].product_id}-->
  </div>
  
  ↓↓↓ 以下の様に修正 ↓↓↓
  
  <div id="disp_url<!--{$smarty.section.cnt.iteration}-->" style="display:none">
    <!--{$smarty.const.HTTP_URL}-->products/detail<!--{$arrProducts[cnt].product_id}-->.php
  </div>

この要領でモバイル、スマートフォンサイトも修正したらOK

Comments are closed.