打印

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

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

制作伪静态文件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;

TOP

从网上找到的opencart 2.1版本的,修改后的完整虚拟主机配置如下
复制内容到剪贴板
代码:
server {
    server_name 域名;
    root /home/wwwroot/网站目录;
    index index.php index.html;

    listen 80;

    include enable-php.conf;

    location /image/data {
        autoindex on;
    }
    location /admin {
        index index.php;
    }
    location / {
        try_files $uri @opencart;
    }
    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
   
    # 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!
    location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
        deny all;
    }
    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }
    location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
        expires max;
        log_not_found off;
    }
   
    access_log /home/wwwlog/域名.log;  
}
好像有说需要开pathinfo的,如果要pathinfo的话把 include enable-php.conf; 改成 include enable-php-pathinfo.conf;

LNMP付费问题排查/LNMP技术支持/Paypal信用卡代付/代购VPS,域名,软件等 QQ 503228080 旺旺 lzhenbao
军哥淘宝店铺
QQ/旺旺仅提供代购及付费代维/问题解决等服务,其他不回复!LNMP相关问题请在本论坛发帖,提问前先搜索,按https://bbs.vpser.net/thread-2555-1-1.html 要求反馈问题!

TOP