wordpress - nginx 正在返回 301 Moved Permanently

标签 wordpress ubuntu nginx http-status-code-301

如果我的问题与另一个问题相似,我深表歉意,但我无法找到可以帮助我解决问题的答案。
因此,在带有 ubuntu 的本地 pc 上,我已经安装并配置了 nginx + wordpress(如 stackoverflow 中所述),一切正常,但我无法从远程 pc 访问我的网站。我已经在 noip 上创建了主机名并将所有重定向到路由器,但 nginx 不断返回 301。任何帮助将不胜感激。

配置文件:

server {
        listen 80;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/html;
        index index.php index.html index.htm;

        server_name localhost;

        location / {
                #try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
    }

}

curl -I mylocalwebsite.ddns.net
HTTP/1.1 301 Moved Permanently
Server: nginx/1.4.6 (Ubuntu)
Date: Wed, 19 Oct 2016 10:36:14 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.5.9-1ubuntu4.20
Set-Cookie: PHPSESSID=ku8vc501u9srdeqh08cnsdvht6; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: http://localhost/

文件:/var/log/nginx/access.log
85.105.338.54 - - [19/Oct/2016:12:38:25 +0200] "HEAD / HTTP/1.1" 301 0 "-" "curl/7.35.0"

最佳答案

Wordpress 在其配置中具有静态域名,如果您将其设置为 localhost,并使用 IP 或指向您的 wordpress 安装的其他域名访问它,它将重定向到 localhost。

您是否尝试在设置中设置您的 wordpress 域名,与您的 noip 域名相同? (例如 mylocalwebsite.ddns.net)。在您的 wordpress 设置中检查它。

关于wordpress - nginx 正在返回 301 Moved Permanently,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40129238/

相关文章:

node.js - Nginx负载均衡不就是像代理服务器一样吗?

php - 如果是动画 gif,请禁用图像调整大小

jquery - 使用 jQuery 尝试更改文本框的背景颜色但在 WordPress 中不起作用

javascript - Wordpress - 未捕获的语法错误 : Unexpected token <

mysql 5.7数据目录里面有文件

ubuntu - 我现在由 NginX 提供服务的网站的正确权限是什么?

linux - 如何让两个docker容器可以互相ping通

c++ - 如何放大 'free memory'

java - 从应用程序外部测试应用程序服务的最佳方法

node.js - Node+Express+NGINX 应用程序返回 localhost 而不是域