2016-03-02 229 views
-1

我想要的標籤
www.store.com/index.php?route=product/search&tag=Mercury 的URL更改爲
www.store.com/tag/MercuryOpencart標籤url seo友好嗎?

我試着用

 } elseif ($data['route'] == 'product/search' && $key == 'tag') { 

         $url .= '/tag/' . $value; 

         unset($data[$key]); 

        } elseif ($key == 'path') { 

但無濟於事改變catalog/controller/common/seo_url.php 替代代碼的代碼,

當然opencart搜索引擎優化網址友好是關於和工作罰款的其他東西,如產品和種類s,

我該如何解決?

回答

0

你有沒有嘗試過這樣的:在您的.htaccess文件

補充一點:

RewriteRule ^tag/([^?]*)? /search?tag=$1 [L,QSA] 

前:

RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] 

然後在你的product.tpl 改變那些:

<a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['tag']; ?></a> 

到:

<a href="<?php echo 'tag/'.$tags[$i]['tag']; ?>"><?php echo $tags[$i]['tag']; ?></a> 

這樣你就不必處理核心文件。

希望有所幫助。

//編輯

這裏是你的product.tpl部分

<?php if ($tags) { ?> 
    <p><?php echo $text_tags; ?> 
    <?php for ($i = 0; $i < count($tags); $i++) { ?> 
    <?php if ($i < (count($tags) - 1)) { ?> 
    <!-- <a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['tag']; ?></a> --> 
    <a href="<?php echo 'tag/'.$tags[$i]['tag']; ?>"><?php echo $tags[$i]['tag']; ?></a>, 
    <?php } else { ?> 
    <!-- <a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['tag']; ?></a> --> 
    <a href="<?php echo '/tag/'.$tags[$i]['tag']; ?>"><?php echo $tags[$i]['tag']; ?></a> 
    <?php } ?> 
    <?php } ?> 
    </p> 
    <?php } ?> 

的.htaccess

RewriteBase/
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L] 
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L] 
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L] 
RewriteRule ^tag/([^?]*)? index.php?route=product/search&tag=$1 [L,QSA] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) 
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]