nginx重写:从URL删除子目录和文件扩展名

时间:2019-03-04 23:38:32

标签: ubuntu nginx

我超级卡在这里,如何将mydomain.com/php/hello-world.php转换为mydomain.com/hello-word ...下面的示例仅下载我的php文件,而不显示内容。请帮助

server {
        listen 80;
        server_name mydomain.com www.mydomain.com;

        root /var/www/mydomain;
        index index.php;

        location / {
                try_files $uri $uri/ /php$uri.php =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        }

}

0 个答案:

没有答案