Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
304 views
in Technique[技术] by (71.8m points)

wordpress - Nginx downloads file instead of redirecting

So I have a domain setup with this nginx config:

server {
    root /var/www/reallyuhc.com/html;
    index index.php;
    server_name reallyuhc.com www.reallyuhc.com;

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

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

server {
    if ($host = www.reallyuhc.com) {
        return 301 https://$host$request_uri;
    }

    if ($host = reallyuhc.com) {
        return 301 https://$host$request_uri;
    }

    listen 80;
    listen [::]:80;
    server_name reallyuhc.com www.reallyuhc.com;
    return 404;
}

Now the issue is that if I do domain.com/index, I see the index file, but doing domain.com will just download that file.

What is missing here? It's all working fine, only the / downloads the file instead of showing the index file. Is this something related to Wordpress? Wordpress is installed for that domain.

question from:https://stackoverflow.com/questions/66050059/nginx-downloads-file-instead-of-redirecting

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...