nginx 上的 OpenCart
Posted
技术标签:
【中文标题】nginx 上的 OpenCart【英文标题】:OpenCart on nginX 【发布时间】:2013-03-15 14:10:41 【问题描述】:OpenCart 能否在 nginx 上使用 SEO URL?我知道在 Apache 中,它会创建一个 .htaccess,但它是否能够自动管理 nginX 中的 URL 重定向?
【问题讨论】:
是什么阻止你尝试? 【参考方案1】:Nginx 上的 OpenCart - 我们已经使用了一年。最后,似乎其他人开始使用它。获得帮助是一场噩梦,有时进入 Nginx 很棘手..
下面是我的www.site.com.vhost
,例如:
# FORCE WWW
server
server_name site.com;
rewrite ^(.*) http://www.site.com$1 permanent;
# MAIN SERVER
# NINX 0.8.54 - WORKS ON 1.1.19
server
server_name www.site.com;
listen 80;
root /var/www/www.site.com/web;
index index.php index.html;
location /image/data
autoindex on;
location /admin
index index.php;
location /
try_files $uri @opencart;
location @opencart
rewrite ^/(.+)$ /index.php?_route_=$1 last;
location = /favicon.ico
log_not_found off;
access_log off;
location = /robots.txt
allow all;
log_not_found off;
access_log off;
# 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;
location ~ \.php$
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
好的,现在关于管理您的网站。您现在可以通过管理员启用 SEO,查看我的其他帖子 tagged nginx and opencart 了解所有 URL,并使用 location /
进一步自定义
我还建议阅读有关删除 index.php?route= - 链接如下:
Remove index.php?route=common/home from OpenCart
【讨论】:
我也会警惕audoindex on;
这是因为我们使用 CDN,最好将这些文件夹保密。
您能否详细说明您的设置。我尝试使用您的配置,但它似乎根本不起作用。我缺少有关您的 FastCGI 设置等的背景信息。
请发布您自己的问题@daemonfire300,因为此设置确实有效。我们在所有 OpenCart 平台安装中使用 NGINX。 autoindex on
去掉这个,相当于显示index of /
并列出所有文件...以上是关于nginx 上的 OpenCart的主要内容,如果未能解决你的问题,请参考以下文章