搜索
开启辅助访问 切换到宽版

QQ登录

只需一步,快速开始

扫一扫,访问微社区

注册 找回密码
查看: 11895|回复: 26
打印 上一主题 下一主题

OpenCart完美伪静态方案Version 1.5.5.1实例方案

  [复制链接]
跳转到指定楼层
楼主
发表于 2013-9-5 10:04:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
最近研究Opencart系统,发现此系统的伪静态竟然不怎么完善。
故综合往年开发者一些经验,自己研究结果,总结如下:
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏2 分享分享 支持支持1 反对反对
回复

使用道具 举报

推荐
 楼主| 发表于 2013-9-5 10:14:23 | 只看该作者
C.查找到

  1. elseif ($key == 'path') {
复制代码
在其代码前添加

  1. elseif (in_array($data['route'],$urlAlias)) {
  2.     $value = str_replace('/','=',$value);
  3.     $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($value) . "'");
  4.     if ($query->num_rows) {
  5.         $url .= '/' . $query->row['keyword'];                        
  6.         unset($data[$key]);
  7.     }                                       
  8. }
复制代码
回复 支持 0 反对 1

使用道具 举报

沙发
 楼主| 发表于 2013-9-5 10:05:53 | 只看该作者
Part 1
路径文件/catalog/controller/common/seo_url.php

此文件一共添加3个部分
回复 支持 反对

使用道具 举报

板凳
 楼主| 发表于 2013-9-5 10:06:17 | 只看该作者
A.查找到

  1. } else {
  2.           $this->request->get['route'] = 'error/not_found';        
  3. }
复制代码
在其代码前添加

  1. if ($url[0] == 'common') {
  2.     $this->request->get['route'] = 'common/'.$url[1];
  3. }

  4. if ($url[0] == 'account' && $url[1] == 'return' && $url[2] == 'insert') {
  5.     $this->request->get['route'] = 'account/'.$url[1].'/'.$url[2];
  6. }elseif ($url[0] == 'account') {
  7.     $this->request->get['route'] = 'account/'.$url[1];
  8. }

  9. if ($url[0] == 'checkout') {
  10.     $this->request->get['route'] = 'checkout/'.$url[1];
  11. }

  12. if ($url[0] == 'information') {
  13.     $this->request->get['route'] = 'information/'.$url[1];
  14. }

  15. if ($url[0] == 'product') {
  16.     $this->request->get['route'] = 'product/'.$url[1];
  17. }
复制代码
回复 支持 反对

使用道具 举报

地板
 楼主| 发表于 2013-9-5 10:08:22 | 只看该作者
B.查找到

  1. foreach ($data as $key => $value) {
复制代码
在此代码下方增加

  1. $urlAlias = array(
  2.     'account/register',
  3.     'account/login',
  4.     'account/logout',
  5.     'account/password',
  6.     'account/history',
  7.     'account/edit',
  8.     'account/account',
  9.     'account/wishlist',
  10.     'account/newsletter',
  11.     'account/order',
  12.     'account/forgotten',
  13.     'account/address',
  14.     'account/download',
  15.     'account/transaction',
  16.     'account/return/insert',
  17.     'account/return',
  18.     'account/voucher',
  19.     'account/reward',
  20.     'common/home',
  21.     'checkout/cart',
  22.     'checkout/checkout',
  23.     'information/contact',
  24.     'information/sitemap',
  25.     'product/compare',
  26.     'product/search',
  27.     'product/special',
  28. );
复制代码
回复 支持 反对

使用道具 举报

6#
 楼主| 发表于 2013-9-5 10:19:26 | 只看该作者
Part 2
导入SQL对应伪静态文件

sql.zip (508 Bytes, 下载次数: 165)

回复 支持 反对

使用道具 举报

7#
 楼主| 发表于 2013-9-5 10:26:15 | 只看该作者
Part 3
如果你是Apache环境
将根目录文件.htaccess.txt改名为.htaccess

如果你是Nginx环境
打开服务器找到对应的Nginx配置文件(默认服务器安装路径/usr/local/nginx/conf/vhost/域名.conf)
键在location ~ .*\.(php|php5)?$字段前添加如下内容(abc.com请换成你自己的域名)

  1. location / {
  2.      if ($host != 'www.abc.com') {
  3.              rewrite ^/(.*)$ https://www.abc.com/$1 permanent;
  4.      }
  5.      try_files $uri @opencart;
  6. }

  7. location @opencart {
  8.      rewrite ^/(.+)$ /index.php?_route_=$1 last;
  9. }

  10.      location /admin/ {
  11.      index index.php;
  12.      }

  13. location ~* (\.(tpl|ini))$ {
  14.        deny all;
  15. }
复制代码
回复 支持 反对

使用道具 举报

8#
 楼主| 发表于 2013-9-5 10:40:36 | 只看该作者
本帖最后由 nowbe 于 2013-9-5 10:41 编辑

Part 4
登录你的网站后台(www.abc.com/admin/index.php)


找到  系统设置>>网店设置>>编辑网店>>服务器设置>>高级URL Rewrite 选择开启

对应英文路径不记得了


未完问题大家可以回帖留言。
我在更新此贴。

技术问题可以找我来咨询,一起探讨一下。
nowbe2004#126.com
看到邮件留言我有时间会回复你的。
回复 支持 反对

使用道具 举报

9#
发表于 2013-9-5 20:44:12 | 只看该作者
不错,支持下:)
回复 支持 反对

使用道具 举报

10#
发表于 2013-9-8 21:54:41 | 只看该作者
亲,这个1.5.6可以用吗?菜鸟?谢谢

下载,照抄照搬,祝我成功
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

QQ|手机版|OpenCart - 中文官方网站 ( 蜀ICP备09033774号|人工智能

GMT+8, 2024-4-25 19:35 , Processed in 0.069632 second(s), 23 queries , Gzip On.

快速回复 返回顶部 返回列表