2

我对 nginx 有点陌生,并且在重写时遇到了困难。我试图得到:

/c/545_453453_4534

访问 c.php 传递 545_453453_4534 作为参数

这是我目前的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;
    }

谢谢!

4

1 回答 1

0

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

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

我倾向于生成我重写的 Apache 样式,然后使用以下命令将其转换为 NGINX 格式:

http://www.anilcetin.com

于 2014-03-24T23:55:51.180 回答