wordpress - 代理通过 nginx 将 mywebsite 传递到另一个服务器 wordpress 博客
问题描述
我确实将 mywebsite.com/blog 代理传递到另一个服务器,该服务器在该服务器上提供了 wordpress。
当我访问 mywebsite.com/blog 时一切正常,但是当我在 wordpress 管理员上做某事或编辑某事时,它突然重定向到 mywebsite.com/wp-admin 而不是 mywebsite.com/blog/wp-admin
这是我的主要 website.com nginx 配置:
server {
listen 80;
server_name mywebsite.com;
root /var/www/html/laravel-app/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ^~ /blog/ {
rewrite ^/blog(/?.*)$ $1 break;
proxy_set_header Host 1.2.3.4;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://1.2.3.4/;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
这是另一个为 wordpress 博客服务的服务器:
server {
listen 80;
root /var/www/html/wordpress-blog;
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
解决方案
尝试在 Wordpress 数据库上运行这个通用的 mySQL 查询(用 mywebsite.com 和 mywebsite.com/blog 替换 olddomain 和 newdomain):
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://olddomain.com', 'http://newdomain.com');
推荐阅读
- python - 注册 Key_acute 事件在第一次按键时不起作用
- python - 有人知道模仿 TradingView 编辑器的 Python 脚本吗?
- reactjs - Firebase 和 React:CollectionReference.doc() 参数类型
- error-handling - 在 SAS Studio 中访问 SASHELP.ZIPCODE.DATA 的错误代码
- firebase - I/flutter (22027):MissingPluginException(在通道 plugins.flutter.io/cloud_firestore 上找不到方法 DocumentReference#setData 的实现)
- java - Spring MVC 在 WAR 和 JAR 文件中带有 jsp 文件
- php - 试图验证 JWT 签名 Tymon/jwt-auth laravel
- python - 使用 BeautifulSoup Python 进行 Web 抓取返回 None
- r - R:基于超过 1 个变量对记录进行分类
- python - 在 Python 中打印某些 JSON 数据