【问题标题】:Opencart tags url seo friendly?Opencart 标签 url seo 友好吗?
【发布时间】:2016-03-02 08:19:08
【问题描述】:

我想更改标签的url
www.store.com/index.php?route=product/search&tag=Mercury
www.store.com/tag/Mercury

我尝试更改catalog/controller/common/seo_url.php的代码 将代码替换为

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

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

                        unset($data[$key]);

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

但无济于事,

当然opencart seo url friendly 已启用,并且在产品和类别等其他方面工作正常,

我该如何解决?

【问题讨论】:

    标签: php url seo opencart


    【解决方案1】:

    你试过了吗:

    在您的 .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>
    

    这样您就不必操作核心文件。

    希望对您有所帮助。

    //编辑

    这是您产品中的部分.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]
    

    【讨论】:

      猜你喜欢
      • 2017-09-29
      • 1970-01-01
      • 1970-01-01
      • 2016-05-02
      • 1970-01-01
      • 1970-01-01
      • 2011-08-25
      • 1970-01-01
      相关资源
      最近更新 更多