• 欢迎访问趣尚博客、分享互联网、软件、编程、创业、英语、VPS 推荐使用最新版火狐浏览器和Chrome浏览器访问本网站
  • 如果您喜欢我的博客,那么请使用Ctrl+D 收藏吧!

实现opencart 2.3全站伪静态化

OpenCart建站 qushang 2年前 (2019-04-03) 118次浏览 0个评论

Opencart在开启伪静态功能之后

更改htaccess.txt为.htaccess

在catagory和product 的seo_keyword处添加相应的伪静态文字

注册不要重复 建议分类名或产品名加ID

这样分类和产品就实现了静态化

其它页的静态化先修改文件2.3.0.2的在catalog/controller/startup/seo_url.php

在大概103行那边

} elseif ($key == 'path') {
$categories = explode('_', $value);

foreach ($categories as $category) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");

if ($query->num_rows && $query->row['keyword']) {
$url .= '/' . $query->row['keyword'];
} else {
$url = '';

break;
}
}

unset($data[$key]);
}

后面加上

if ($key == 'route') { 
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($value) . "'"); 
if ($query->num_rows) { 
$url .= '/' . $query->row['keyword']; 
unset($data[$key]); 

再修改数据库

执行

INSERT INTO url_alias (query, keyword) VALUES ('common/home', ''); 
INSERT INTO url_alias (query, keyword) VALUES ('account/wishlist', 'wishlist'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/account', 'my-account'); 
INSERT INTO url_alias (query, keyword) VALUES ('checkout/cart', 'shopping-cart'); 
INSERT INTO url_alias (query, keyword) VALUES ('checkout/checkout', 'checkout'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/login', 'login'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/logout', 'logout'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/order', 'order-history'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/newsletter', 'newsletter'); 
INSERT INTO url_alias (query, keyword) VALUES ('product/special', 'specials'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/account', 'affiliates'); 
INSERT INTO url_alias (query, keyword) VALUES ('checkout/voucher', 'gift-vouchers'); 
INSERT INTO url_alias (query, keyword) VALUES ('product/manufacturer', 'brands'); 
INSERT INTO url_alias (query, keyword) VALUES ('information/contact', 'contact-us'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/return/insert', 'request-return'); 
INSERT INTO url_alias (query, keyword) VALUES ('information/sitemap', 'sitemap'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/forgotten', 'forgot-password'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/download', 'downloads'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/return', 'returns'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/transaction', 'transactions'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/register', 'create-account'); 
INSERT INTO url_alias (query, keyword) VALUES ('product/compare', 'compare-products'); 
INSERT INTO url_alias (query, keyword) VALUES ('product/search', 'search'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/edit', 'edit-account'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/password', 'change-password'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/address', 'address-book'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/reward', 'reward-points'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/edit', 'edit-affiliate-account'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/password', 'change-affiliate-password'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/payment', 'affiliate-payment-options'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/tracking', 'affiliate-tracking-code'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/transaction', 'affiliate-transactions'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/logout', 'affiliate-logout'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/forgotten', 'affiliate-forgot-password'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/register', 'create-affiliate-account'); 
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/login', 'affiliate-login');
INSERT INTO url_alias (query, keyword) VALUES ('account/voucher', 'account-voucher'); 
INSERT INTO url_alias (query, keyword) VALUES ('account/return/add', 'account-return-add');


极客公园 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:实现opencart 2.3全站伪静态化
喜欢 (0)
[399397742@qq.com]
分享 (0)
发表我的评论
取消评论

*

code

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址