VPS侦探论坛

 找回密码
 注册
查看: 10060|回复: 2

求CS-CART的nginx静态化配置方法

[复制链接]
发表于 2010-9-11 23:54:00 | 显示全部楼层 |阅读模式

我现在在/usr/local/nginx/conf/里面建立了一个cs-cart.conf的文件,内容是
location ~ /\.ht {
        deny  all;
    }
    location / {
        root /home/wwwroot;
        index index.php;
        try_files $uri $uri/ /index.php?sef_rewrite=1;
    }
    location ~ /catalog {
        try_files $uri/index.html /index.php?sef_rewrite=1;
    }
接着.htaccess文件内容是
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite ^ /index.php?sef_rewrite=1;
}

结果在后台设置的时候不行,提示是
SEO-friendly URLs are disabled. Check your web server and URL manipulation engine settings.

参考http://www.ekuzo.com/cs-cart-nginx-fastcgi-seo-urls-rewrite-699
server {
listen 80;
server_name ekuzo.com www.ekuzo.com;
location / {
root /var/www/html/ekuzo;
index index.php index.html index.htm;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite ^ /index.php?sef_rewrite=1;
}
}
location ~ .php$ {
root /var/www/html/ekuzo;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~ /.ht {
deny all;
}
}

其中下面的一段是URL的重写规则:

if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite ^ /index.php?sef_rewrite=1;
}
还有CS-CART这个http://forum.cs-cart.com/showthread.php?t=13726&highlight=nginx
# Deny acces to .htaccess files in case i forget to remove them.
    location ~ /\.ht {
        deny  all;
    }
# Main location to serve static files.
    location / {
        root /srv/http/mir-shin/htdocs;
        index index.php;
# First rewrite rule: this rule tries to access file of the request,
# if failed - directory, and if that also fails - rewrites request to php.
        try_files $uri $uri/ /index.php?sef_rewrite=1;
    }
# Location for static catalog, which i don't use, but decided to leave
# it in my config in case I'll decide to actually use static catalog.
    location ~ /catalog {
        try_files $uri/index.html /index.php?sef_rewrite=1;
    }

.htaccess文件内容
f (-f $request_filename) {
break;
}

if (-d $request_filename) {
break;
}

rewrite ^ /index.php?sef_rewrite=1;

都不成功。并且有重启nginx服务还是不成功。请求各位高手给予帮助
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2010-9-12 13:59:06 | 显示全部楼层


继续求助啊!希望能得到解决
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2010-9-12 18:49:00 | 显示全部楼层

回复 1# 的帖子


apache的.htaccess伪静态规则是无法直接添加到nginx上用的。先用http://blog.licess.org/convert-apache-htaccess-to-nginx/ 方法转换成nginx的(转换后不一定100%可以用最好是想他们官方要一个nginx的伪静态规则)。
如果cs-cart.conf 只你存放伪静态规则的文件,那么你直接在虚拟主机配置里面include cs-cart.conf;重启nginx就行了。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-10-18 12:28 , Processed in 0.026187 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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