Nginx 服务器 301 永久移动

Nginx 服务器 301 永久移动

当我做 curl -v 时http://site-wordpress.com:81我收到了这个结果:

* About to connect() to site-wordpress.com port 81 (#0)
*   Trying ip... connected
* Connected to site-wordpress.com (ip) port 81 (#0)

> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-unknown-linux-gnu) libcurl/7.19.7 NSS/3.12.6.2 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
> Host: site-wordpress.com:81
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.2.4
< Date: Fri, 16 Nov 2012 16:28:19 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Pingback: The URL above/xmlrpc.php
< Location: The URL above

看来我的 fastcgi_params 中的这行造成了麻烦。

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

如果我删除此行,我会得到 HTTP/1.1 200 OK,但我得到一个空白页。

这是我的配置:

server {
       listen 81;
       server_name site-wordpress.com;
       root /var/www/html/site;
       access_log  /var/log/nginx/access.log;
       error_log   /var/log/nginx/error.log;
        index index.php;
        if (!-e $request_filename){
                rewrite ^(.*)$ /index.php break;
       }



    location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;  # port where FastCGI processes were spawned
                fastcgi_index index.php;
                include /etc/nginx/fastcgi_params;
                include /etc/nginx/mime.types;
                }

    location ~ \.css {
                 add_header Content-Type text/css;
                 }

    location ~ \.js {
                add_header Content-Type application/x-javascript;
                }

}

此配置适用于 ip 和端口 80。但现在我需要使用域名和端口 81,这不起作用。有人可以帮忙吗?谢谢。

答案1

这是您的 WordPress 配置问题,而不是您的 nginx 配置问题。如果您确实想在端口 81 上运行服务器,那么您必须修改 WordPress 选项中的 URL。

相关内容