Php 清理Nginx重写的URL

Php 清理Nginx重写的URL,php,.htaccess,mod-rewrite,url-rewriting,nginx,Php,.htaccess,Mod Rewrite,Url Rewriting,Nginx,在互联网上搜索了几个小时后,没有一个导游在工作,我向你们寻求帮助 我正在尝试清除任何目录中所有文件的所有URL,以便www.foo.com/foo.php变为www.foo.com/foo 我还想整理请求,例如www.foo.com/foo.php?foo=foo到www.foo.com/foo/foo 以下是我当前失败的尝试: server { # Change these settings to match your machine listen 80 default

在互联网上搜索了几个小时后,没有一个导游在工作,我向你们寻求帮助

我正在尝试清除任何目录中所有文件的所有URL,以便www.foo.com/foo.php变为www.foo.com/foo

我还想整理请求,例如www.foo.com/foo.php?foo=foo到www.foo.com/foo/foo

以下是我当前失败的尝试:

    server {
    # Change these settings to match your machine
    listen 80 default_server;
    server_name example.com www.example.com;

    # Everything below here doesn't need to be changed
    access_log /var/log/nginx/example.access.log;
    error_log /var/log/nginx/example.error.log;

    root /var/www/example.com;
     try_files $uri $uri/ @extensionless-php;
    index index.html index.htm index.php;

    location ~ \.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;

            # The next two lines should go in your fastcgi_params
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    location @extensionless-php {
        rewrite ^(.*)$ $1.php last;

   }
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;
       }
       }
它可以工作,但我仍然可以访问旧的.php url,据我所知,这对SEO不好?作为它的复制内容

提前谢谢 丹尼