實現opencart 2.3全站偽靜態化

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');


上一篇:在opencart2.3訂單號改成時間月日時分秒 下一篇:修改opencart2.3 SMTP設置聯系我們郵件出錯
  • 版權聲明:內容來自互聯網不代表本站觀點,2018-05-14發表于 OpenCart教程欄目。
  • 轉載請注明: 實現opencart 2.3全站偽靜態化| OpenCart教程 +復制鏈接