Nginx Rewrite不起作用,它下载文件

时间:2019-04-23 14:33:50

标签: nginx url-rewriting

当我尝试打开URL时,它会下载文件

例如,如果我输入example.com/aboutus,则浏览器将下载一个名为“ aboutus”的文件

如果我打开文件,则该文件包含aboutus.php的PHP代码

请帮助我

此重写有什么问题?

server {
        root /var/www/example.com/html;
        index index.php index.html index.htm;

        server_name example.com www.example.com;

        location / {
            try_files $uri $uri/ /index.php?$args;
            rewrite ^/aboutus/(.*)$ /index.php?mod=aboutus last;
            rewrite ^/sitemap/?$ /index.php?mod=sitemap last;
        }

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

        location ~ /\.ht {
            deny all;
        }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com) {
        return 301 https://www.$host$request_uri;
    } # managed by Certbot


        listen 80;
        listen [::]:80;

        server_name example.com www.example.com;
    return 404; # managed by Certbot

}

0 个答案:

没有答案