使用nginx-非常简单的设置和问题,我尝试将所有内容移到根目录下的博客目录中,但wordpress 301s从example.com/blog回到了example.com。我认为我缺少明显的东西或wordpress内有东西导致此,但无法弄清楚
这是我的Nginx块,当从/投放时,该块有效。
server {
listen 80 ;
server_name $SITE_URL;
server_name _;
# note that these lines are originally from the "location /" block
root /var/www/vhosts/$SITE_URL/httpdocs;
index index.php index.html index.htm;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?" part so non-default permalinks doesn't break when using query string
try_files \$uri \$uri/ /index.php?\$args;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)\$ {
expires max;
log_not_found off;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.(php|phar)(/.*)?\$ {
fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)\$;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_intercept_errors on;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param PATH_INFO \$fastcgi_path_info;
}
}
所以我的第一个尝试是将所有内容移动到目录中的httpdocs / blog
并添加
location /blog {
# This is cool because no php is touched for static content.
# include the "?" part so non-default permalinks doesn't break when using query string
try_files \$uri \$uri/ /blog/index.php?\$args;
}
location ~ \.(php|phar)(/.*)?$ {
fastcgi_split_path_info ^(/blog\.(?:php|phar))(/.*)$;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_intercept_errors on;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
但没有运气
修改 我刚刚注意到ip.com/bloggg将重定向到ip.com/gg,所以我认为某处有一些规则,但是我不知道。.在nginx中我看不到它
Edit2
原来博客中有一个重定向插件,重写了/ blog ...哎呀
答案 0 :(得分:0)
编辑您的Wordpress常规设置,根据需要更改两个URL。
“站点地址(URL): 输入您希望人们在浏览器中键入的地址以访问您的WordPress网站。 [...]“
仔细阅读您需要更改的内容。
答案 1 :(得分:-1)
您应该为该wordpress下载sql文件,并用新的网址(例如“ {http://example.com”到“ http://example.com/blog”)替换旧的网址