将 .htaccess 转换为 nginx

将 .htaccess 转换为 nginx
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) p.php?id=$1 [L,QSA] 

我该如何改变它才能与 nginx 一起工作?

另外,我应该把它放在哪里?

server {
        listen       80;
        server_name site.com www.site.com;
        root /home/site/public_html;

        location / {
            root   /home/site/public_html;
            index  index.html index.htm;
                proxy_pass http://www.site.com;
                proxy_cache my-cache;
                proxy_cache_valid  200 302  60m;
                proxy_cache_valid  404      1m;
                location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
                        expires 30d;
                }
        }
        location ~ \.php$ {
            root           /home/site/public_html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}

答案1

相关内容