我已经创建了一个Wordpress多站点,但是当我进入一个多站点时,它会自动在首页URL后面添加斜杠。我的多站点也位于子目录中,我不确定这是否会对其产生影响。例如:
www.example.com/core/resource/site1
重定向到:
www.example.com/core/resource/site1/
我试图更新数据库并修改URL,以使它们不包含斜杠,但是当我这样做时,站点中断了。它仍然尝试重定向,并且出现“建立数据库连接错误”页面。符合预期。
这是我当前在nginx配置中拥有的:
server {
listen 443 ssl;
server_name example.com;
access_log /var/log/nginx/mysite.com/access.log;
error_log /var/log/nginx/mysite.com/error.log error;
root /data/wordpress/mysite;
index index.html index.php;
rewrite ^/$ /wp/index.php break;
# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite ^/(wp-admin/.*)$ /wp/$1 last;
rewrite ^/core/resource(/[^/]+)?(/wp-admin/.*)$ /core/resource/wp/$2 last;
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/core/resource(/[^/]+)?(/wp-.*) /core/resource/wp$2 last;
rewrite ^/core/resource(/[^/]+)?(/.*\.php)$ /core/resource/wp$2 last;
}
location /core/resource {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /core/resource/wp/index.php?$args;
}
rewrite ^/(wp-includes/.*)$ /core/resource/wp/$2 last;
include global/media.conf;
include global/php.conf;
include global/wordpress-w3tc.conf;
client_max_body_size 20M;
ssl on;
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 {
listen 80;
server_name example.com;
return 301 https://www.example.com$request_uri;
}
谁能建议我如何防止wordpress多站点自动尾部斜杠?预先感谢。
答案 0 :(得分:0)
我已通过将remove_filter('template_redirect', 'redirect_canonical');
添加到我的functions.php文件中来解决此问题。我还必须清除浏览器中的缓存。