WordPress伪静态规则设置(迁移网站需要重写规则)

1、IIS的Wordpress伪静态规则配置
创建httpd.ini 文件,将以下内容粘贴到文件中,然后上传到WordPress站点的根目录即可。


[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32

# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]

2、Nginx的Wordpress伪静态规则配置
在Nginx的虚拟主机配置文件中,在 server { } 大括号里面,加入以下代码:


location / {
try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

保存,重启 Nginx 即可。

3、Apache的Wordpress伪静态规则配置
编辑httpd.conf(在那里? APACHE目录的CONF目录里面)

查找

Options FollowSymLinks
AllowOverride None

改为
Options FollowSymLinks
AllowOverride All

如果已经开启了htaccess,则直接进入下一步:

新建一个 htaccess.txt 文件,添加下面的代码:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

然后上传到 WordPress 站点的根目录,重命名为 .htaccess 即可

PHP网站提升80%加载速度

运行环境:Nginx 1.15 +  PHP-7.0 + MySQL 5.6

优化:
1、安装,并开启BBR或者BBRplus版(低带宽和低内存不推荐使用锐速)
链接:开启BBR
作用:谷歌公司开发BBR对线路流畅程度,有较大的保障。

2、网站开启TLS1.3
必须:Nginx 1.15
网站的配置文件加上TLSv1.3相关配置,如下(不要再使用TLSv1):

ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
#ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;

作用:开启TLS1.3可以有效减少握手次数,略微缩短访问时间,修改完网站配置需要重启Nigx。

3、安装三个PHP扩展:opcache、memcached、redis;
特别是redis一定要安装上,提速非常明显。

安装方法……请百度
作用:
opcache、memcached都是内容缓存,简单易懂。
redis相当于把数据库放入内存中,不需要每次都到硬盘访问数据,提速非常明显。

注意:WordPress在大陆使用,需要先替换谷歌字体和部分css、js等,因为谷歌屏蔽了,必须替换,否则载入不了。