lwbing 发表于 2011-2-9 15:25:08

求问一个LNMP的NGINX伪静态规则问题。

1,我的主站.htaccess的规则如下:Options +FollowSymLinks
RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^download/(.*)/(.*)$ index.php?id=$1

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^remove/(.*)/(.*)/(.*)$ index.php?id=$2&remove=$1



2,我用自动转换规则的那个地址转换:
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

3,转换后得到:
#ignored: condition 0
if (!-d $uri){

set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){

rewrite ^/download/(.*)/(.*)$ /index.php?id=$1 last;
}
#ignored: condition 0
if (!-d $uri){

set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){

rewrite ^/remove/(.*)/(.*)/(.*)$ /index.php?id=$2&remove=$1 last;
}



4,我把转换后的用WinSCP工具直接连接LINUX直接编辑 /usr/local/nginx/conf/nginx.conf 文件;


server

{

listen       80;

server_name 97sis.info;

index index.html index.htm index.php;

root/home/wwwroot;

location / {
#ignored: condition 0
if (!-d $uri){

set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){

rewrite ^/download/(.*)/(.*)$ /index.php?id=$1 last;
}
#ignored: condition 0
if (!-d $uri){

set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){

rewrite ^/remove/(.*)/(.*)/(.*)$ /index.php?id=$2&remove=$1 last;
}

}

location ~ .*\.(php|php5)?$

{

fastcgi_passunix:/tmp/php-cgi.sock;

fastcgi_index index.php;

include fcgi.conf;

}


location /status {

stub_status on;

access_log   off;

}


location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires      30d;

................................................................................


5,我按照这个步骤,然后访问网站,网站可以运行,可是伪静态没有起到作用,求问,我的步骤对吗?哪里设置错了?谢谢回答!

lwbing 发表于 2011-2-9 15:27:26

然后我重启了NGINX

licess 发表于 2011-2-9 15:34:49

回复 1# 的帖子

可能是伪静态的问题,问程序的官方要个nginx的伪静态试试
页: [1]
查看完整版本: 求问一个LNMP的NGINX伪静态规则问题。