2012-07-27 79 views
2

我对nginx来说有些新鲜,并且在重写时遇到困难。我想获得:URL参数和重写

/C/545_453453_4534

访问c.php传递545_453453_4534作为PARAMS

这里是我当前的conf:

location/{ 
     try_files $uri $uri/ @extensionless-php; 
     index index.html index.htm index.php; 
    } 

    location ~ \.php$ { 
      try_files $uri =404; 
      fastcgi_pass 127.0.0.1:8000; 
      include /etc/nginx/fastcgi_params; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 

    location @extensionless-php { 
      rewrite ^(.*)$ $1.php last; 
    } 

谢谢!

回答

0

在你的NGINX服务器块,你需要添加:

rewrite ^/c/([^/]*)$ /c.php?param=$1 last; 

我倾向于做的是生成我重新写Apache的风格,那么用它转换为NGINX格式:

http://www.anilcetin.com