- 在nginx.conf的 server配置中加入如下代码
location / {
autoindex on;
send_timeout 1800;
fastcgi_buffers 8 128k;
fastcgi_intercept_errors on;
if ( !-e $request_filename ) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ ^/shopadmin {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
if ($request_uri ~ (.+?\.php)(|/.*)$ ){
break;
}
配置完成后需重启nginx
- 修改ecstore的config配置,代码如下
define('WITH_REWRITE',true);
- 我自己的nginx.conf文件,仅供参考
user www www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
index index.php index.html index.htm;
root /data/www;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name 192.168.51.67;
if ( $host ~* (.*)\.(.*)\.(.*)){
set $domain $1;
}
location ~ ^/(.*)/data/.*\.(php)?$
{
return 404;
deny all;
}
location ~ ^/(.*)/public/.*\.(php)?$
{
return 404;
deny all;
}
location ~ ^/(.*)/themes/.*\.(php)?$
{
return 404;
deny all;
}
location ~ ^/(.*)/wap_themes/.*\.(php)?$
{
return 404;
deny all;
}
#伪静态配置开始.....
if ($request_uri ~ (.+?\.php)(|/.*)$ ){
break;
}
location / {
autoindex on;
send_timeout 1800;
fastcgi_buffers 8 128k;
fastcgi_intercept_errors on;
#伪静态配置
if ( !-e $request_filename ) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ ^/shopadmin {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
#伪静态配置结束......
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php {
include fastcgi_params;
set $real_script_name $fastcgi_script_name;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
}