VPS侦探论坛

 找回密码
 注册
查看: 3004|回复: 1

lnmp怎么在opencart2.0.3.1中添加伪静态

[复制链接]
发表于 2018-4-9 00:52:05 | 显示全部楼层 |阅读模式

制作伪静态文件opencart.conf 内容
location / {
           
rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last;

rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;

rewrite ^/system/download/(.*) /index.php?route=error/not_found last;
if (!-f $request_filename){

set $rule_3 1$rule_3;
}
if (!-d $request_filename){

set $rule_3 2$rule_3;
}
if ($uri !~ ".*\.(ico|gif|jpg|jpeg|png|js|css)"){

set $rule_3 3$rule_3;
}
if ($rule_3 = "321"){

rewrite ^/([^?]*) /index.php?_route_=$1 last;
}

        }


把文件opencart.conf /usr/local/nginx/conf/rewrite 里面
在/usr/local/nginx/conf/vhost 中修改对应的规则
例如 9,57行 修改为include rewrite/opencart.conf;
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2018-4-9 09:54:46 | 显示全部楼层


从网上找到的opencart 2.1版本的,修改后的完整虚拟主机配置如下
  1. server {
  2.     server_name 域名;
  3.     root /home/wwwroot/网站目录;
  4.     index index.php index.html;

  5.     listen 80;

  6.     include enable-php.conf;

  7.     location /image/data {
  8.         autoindex on;
  9.     }
  10.     location /admin {
  11.         index index.php;
  12.     }
  13.     location / {
  14.         try_files $uri @opencart;
  15.     }
  16.     location @opencart {
  17.         rewrite ^/(.+)$ /index.php?_route_=$1 last;
  18.     }
  19.    
  20.     # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
  21.     location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
  22.         deny all;
  23.     }
  24.     # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
  25.     location ~ /\. {
  26.         deny all;
  27.         access_log off;
  28.         log_not_found off;
  29.     }
  30.     location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
  31.         expires max;
  32.         log_not_found off;
  33.     }
  34.    
  35.     access_log /home/wwwlog/域名.log;  
  36. }
复制代码


好像有说需要开pathinfo的,如果要pathinfo的话把 include enable-php.conf; 改成 include enable-php-pathinfo.conf;
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-11-19 01:21 , Processed in 0.027043 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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