ruman 发表于 2010-9-11 23:54:00

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

我现在在/usr/local/nginx/conf/里面建立了一个cs-cart.conf的文件,内容是
location ~ /\.ht {
      denyall;
    }
    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 {
      denyall;
    }
# 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服务还是不成功。请求各位高手给予帮助

ruman 发表于 2010-9-12 13:59:06

:( 继续求助啊!希望能得到解决

licess 发表于 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就行了。
页: [1]
查看完整版本: 求CS-CART的nginx静态化配置方法