.htaccess FastCGI-重写-使用Nginx定位

.htaccess FastCGI-重写-使用Nginx定位,.htaccess,url-rewriting,nginx,rewrite,.htaccess,Url Rewriting,Nginx,Rewrite,我刚切换到nginx,但是我的URL重写有问题 我曾经 location /id/ { rewrite ^/id/(.*) /index.php?id=$1 break; } 但是php代码没有被解释,最糟糕的是它是原始下载的。 但是.php文件的配置如下: location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php;

我刚切换到nginx,但是我的URL重写有问题

我曾经

location /id/ {
       rewrite ^/id/(.*) /index.php?id=$1 break;
}
但是php代码没有被解释,最糟糕的是它是原始下载的。 但是.php文件的配置如下:

    location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/my_app$fastcgi_script_name;
            include /etc/nginx/fastcgi_params;
    }
我的vhost怎么了

编辑:这是整个vhost 服务器{

    listen   80; ## listen for ipv4
    server_name  viditx.com www.viditx.com; ## change this to your own domain name

   # I find it really useful for each domain & subdomain to have
   # its own error and access log
    error_log /var/log/nginx/viditx.com.error.log;
    access_log  /var/log/nginx/viditx.com.access.log;
root /var/www/viditx;   

location / {
        # Change this to the folder where you want to store your website
        index  index.html index.htm index.php;
}
location /phpmyadmin {
           root /usr/share/;
           index index.php index.html index.htm;
           location ~ ^/phpmyadmin/(.+\.php)$ {
                   try_files $uri =404;
                   root /usr/share/;
                   fastcgi_pass 127.0.0.1:9000;
                   fastcgi_index index.php;
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                   include /etc/nginx/fastcgi_params;
           }
           location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                   root /usr/share/;
           }
    }
    location /phpMyAdmin {
           rewrite ^/* /phpmyadmin last;
    }


    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;

    location = /50x.html {
            root   /var/www/nginx-default;
    }

    location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            # again, change the directory here to your website's root directory
            # make sure to leave $fastcgi_script_name; on the end!
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include /etc/nginx/fastcgi_params;
    }
}您应该尝试:

location /id/ {
       rewrite '^/id/(.*)$' /index.php?id=$1 break;
}
以及:

玩得开心

中断->最后一次

location /id/ {
    rewrite ^/id/(.*)$ /index.php?id=$1 last;
}

不起作用。每当我访问mywebsite.com/id/abc时,php文件仍然会被下载。如果这对我有帮助的话,我按照这个教程给我们你的nginx.conf用整个vhost(没有任何重写)+conf编辑了我的问题谢谢你,先生,我想我没有任何借口,即使我读过它。
location /id/ {
    rewrite ^/id/(.*)$ /index.php?id=$1 last;
}