首页 » SEO优化 » nginxphp切换技巧_WordPress切换到Nginx做事器教程

nginxphp切换技巧_WordPress切换到Nginx做事器教程

访客 2024-11-23 0

扫一扫用手机浏览

文章目录 [+]

对付WordPress站点来说,固定链接紧张是通过根目录下的.htaccess文件来掌握,切换做事器后,Nginx的rewrite格式和Apache的不同,须要修正。

先卸载Apache系统,之后安装Nginx系统。

nginxphp切换技巧_WordPress切换到Nginx做事器教程

在BT面板后台,点“网站”-“设置”-“伪静态”,对付单站点的WordPress来说,原来的.htaccess文件内容如下:

nginxphp切换技巧_WordPress切换到Nginx做事器教程
(图片来自网络侵删)

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

切换到Nginx系统后,其配置内容如下:

location / {

try_files $uri $uri/ /index.php?$args;

}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

对付子域名办法的多站点的WordPress来说,原来的.htaccess文件内容如下:

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ - [L]

RewriteRule ^(wp-(content|admin|includes).) $1 [L]

RewriteRule ^(.\.php)$ $1 [L]

RewriteRule . index.php [L]

切换到Nginx系统后,其配置内容如下:

if (!-e $request_filename) {

rewrite ^.+?(/wp-.) $1 last;

rewrite ^.+?(/.\.php)$ $1 last;

rewrite ^ /index.php last;

}

此外,做事器上还安装了v2ray,原来在Apache里配置的内容如下:

RewriteEngine On

RewriteCond %{HTTP:Upgrade} =websocket [NC]

RewriteRule /test/(.) ws://127.0.0.1:11111/$1 [P,L]

RewriteCond %{HTTP:Upgrade} !=websocket [NC]

RewriteRule /test/(.) http://127.0.0.1:11111/$1 [P,L]

切换到Nginx后,在Nginx做事器配置文件里修正的内容如下:

location /test/ {

proxy_pass http://127.0.0.1:11111/;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection \公众upgrade\公众;

proxy_set_header Host $http_host;

}

相关文章

山东数字经济驱动下的创新发展与优化

山东省以数字经济为核心,积极探索创新发展模式,不断提升产业链、供应链现代化水平,为我国经济发展注入新动力。本文将从山东多个关键词入...

SEO优化 2025-04-05 阅读0 评论0