gpt4 book ai didi

php - Opencart 标签 url seo 友好吗?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:49:05 27 4
gpt4 key购买 nike

我想更改标签的 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 已经打开并且可以很好地处理其他事情,比如产品和类别,

我该如何解决?

最佳答案

你试过这个吗:

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

关于php - Opencart 标签 url seo 友好吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35741788/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com