阿里云为您提供 Nginx 设置 WordPress 伪静态的方法,但是官方描述并不详细,阿里云的共享虚拟主机,由于服务器是 Nginx,原有的 Apache 的伪静态规则就不适用了,因此折腾伪静态规则用了不少时间,为了避免其他人走冤枉路就分享这个教程。
Nginx 的阿里云(万网)虚拟主机是有伪静态配置的地方的,它不需要上传伪静态规则,只需要在主机控X - O制界面设置下,然后重启下站点就可以了,具体的位置: 1 =如下图:
在这里填写如下的伪静态规则就可以了
- locX = i Z k d }ation / {
- try_files $uri $ub O _ z c h D yri/ /index.php?$args;
- }
- # Add trailing slash to */wp-admin requests.
- rewrite /wp-admin$ $sj 3 p Y B W &cheme://$host$uri/ permanent;
设置完& m v ~ V O D ? c伪静态规则后,记得重启虚拟主机,在主机信息那里,先点下% A [ I Z + %停止,再点击下启动即可。这样就设置好了,网站的内) : & n ~页不会出现 404 错误了。
WordPress 安装在 IIS/Apache/Nginx 服务器对应伪静态规则
IIS 伪静态规则
- [ISAPI_Rewrite]
- # Defend your coA @ ? i Q t l :mputer from some worm attacks
- #RewriteRull * X A V Ye .*(?:global.asa|* t C rdefault\.ida|root\.exe|\. 2 a x o b & a ,.\.).* . [F,I,O]
- # 3600 = 17 7 C v ` 9 3 Q 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\?t/ U Z yag=$1
- RewriteRule /software! , v-files/(.*) /sofU V m 8 / s y 7tware-fi; ) R W b h Xles/$1 [L]
- RewriteRule /images/(.*) /images/$1 [L]
- RewriteRule /sitemap.xml /sitemap.xmlN e K z g S j [L]
- RewriteRule /favicon.ico /favicon.ico [L]
- # For file-based wordprn ? 4 o { Jess 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]
Ap z W f X y n + 2pach0 G Ve 伪静态规则
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteBase /
- RewriteRule ^index\.php$ - [L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule . /index.php [L]
- </IfModule>
- NgiI C 2 /nx伪静态规则
- location / {
- try_files $uri $uri/ /inz { Fdex.php?$args;
- }
- # Add trailing slash to */wp-admin requests.
- rewrite /wp-admin$ $scheme://$host$uri/ permaF % g U 2 T M i _nent;