wordpress的Nginx/Apache/IIS伪静态规则

杨泽业 2018年5月7日18:11:27
评论
3,745 views

在我们的WordPress博客里面,安装好WordPress程序以后,就要更换主题,然后就开始配置WordPress的伪静态了。而我这边的教学都是统一使用/%postname%.html这样的自定义结构的。如果这样配置以后,到首页去打开默认的文章,打不开的话,说明当前网站环境不支持WordPress伪静态,需要我们重新配置。

Nginx/Apache/IIS伪静态规则

Nginx/Apache/IIS伪静态规则

如果是阿里云的Linux虚拟主机,直接修改就能打开的,如果是Linux的阿里云服务器,修改了固定连接就打不开了,下面我就针对这样的情况,把wordpress的Nginx/Apache/IIS的伪静态规则发布出来方便大家使用。

NGINX伪静态规则

Nginx环境是Linux服务器里面常见的网站配置环境,完整网站环境是Linux+Nginx+Mysql+PHP简称LNMP环境,他的WordPress伪静态规则是:

  1. location / {
  2.     try_files $uri $uri/ /index.php?$args;
  3. }
  4. # Add trailing slash to */wp-admin requests.
  5. rewrite /wp-admin$ $scheme://$host$uri/ permanent;

把上面的文件放置在当前网站的配置里面,打开 nginx.conf 或者某个独立站点的配置环境,比如 yangzeye.cn.conf(不同人配置的不一样),而我现在的是宝塔管理面板,只要在网站设置里面的伪静态里面复制上面代码保存即可。

 

Apache伪静态规则

Apache环境也是Linux服务器里面常见的网站配置环境,完整网站环境是Linux+Apache+Mysql+PHP简称LAMP环境,他的WordPress伪静态规则是:

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine On
  3. RewriteBase /
  4. RewriteRule ^index\.php$ - [L]
  5. RewriteCond %{REQUEST_FILENAME} !-f
  6. RewriteCond %{REQUEST_FILENAME} !-d
  7. RewriteRule . /index.php [L]
  8. </IfModule>

打开网站根目录下面的.htaccess文件,把上面的代码复制进去,加入没有这个文件的话,新建一个txt文本文档,重命名为.htaccess即可。

 

IIS的伪静态规则

IIS服务器是Windows系统自带的网站服务环境,打开网站根目录的httpd.ini把代码配置进去即可,没有这个文件的新建这个文件。

  1. [ISAPI_Rewrite]
  2. # Defend your computer from some worm attacks
  3. #RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
  4. # 3600 = 1 hour
  5. CacheClockRate 3600
  6. RepeatLimit 32
  7. # Protect httpd.ini and httpd.parse.errors files
  8. # from accessing through HTTP
  9. # Rules to ensure that normal content gets through
  10. RewriteRule /tag/(.*) /index\.php\?tag=$1
  11. RewriteRule /software-files/(.*) /software-files/$1 [L]
  12. RewriteRule /images/(.*) /images/$1 [L]
  13. RewriteRule /sitemap.xml /sitemap.xml [L]
  14. RewriteRule /favicon.ico /favicon.ico [L]
  15. # For file-based wordpress content (i.e. theme), admin, etc.
  16. RewriteRule /wp-(.*) /wp-$1 [L]
  17. # For normal wordpress content, via index.php
  18. RewriteRule ^/$ /index.php [L]
  19. RewriteRule /(.*) /index.php/$1 [L]

好了,今天的wordpress的Nginx/Apache/IIS伪静态规则就讲完了,如果还有疑问的可以在下面留言哦!

  • 泽业营销网官方QQ群
  • 群号:99293363
  • weinxin
  • 我的微信公众号
  • ID:iyangzeye
  • weinxin
杨泽业
  • 本文由 发表于 2018年5月7日18:11:27
  • 转载请务必保留本文链接:https://www.yangzeye.cn/wpwjt.html
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: