国内外主机
测评及优惠码

如何让phpStudy2018 Nginx 支持WordPress自定义链接?

默认phpStudy2018Nginx并不支持WordPress自定义链接,可以通过修改配置文件支持让其支持。如何让phpStudy2018Nginx支持WordPress自定义链接?接下来小编分享的方法只适合Windows本地环境(服务器上没试过)。

如何让phpStudy2018 Nginx 支持WordPress自定义链接?

文本编辑工具打开PHPTutorialnginxconf目录的nginx.conf文件,修改前做个备份,以免修改失误,造成phpStudy无法启动。

搜索autoindex,找到类似:

    server {          listen       80;          server_name  localhost;            #charset koi8-r;            #access_log  logs/host.access.log  main;          root    "I:/phpStudy/PHPTutorial/WWW";          location / {              index  index.html index.htm index.php l.php;             autoindex  on;          }

在其下面添加设置代码,有两种情况:

一、WordPress程序直接安装在PHPTutorialWWW目录中:

if (-f $request_filename/index.html){  rewrite (.*) $1/index.html break;  }  if (-f $request_filename/index.php){  rewrite (.*) $1/index.php;  }  if (!-f $request_filename){  rewrite (.*) /index.php;  }

二、WordPress程序安装在PHPTutorialWWW子目录中,比如:wordpress

if (-f $request_filename/wordpress/index.html){  rewrite (.*) $1/wordpress/index.html break;  }  if (-f $request_filename/wordpress/index.php){  rewrite (.*) $1/wordpress/index.php;  }  if (!-f $request_filename){  rewrite (.*) /wordpress/index.php;  }

修改其中的wordpress为你子目录名称。

最后重启phpStudy,试试设置自定义链接是否可以正常打开了。

phpStudy最新版本是8.0,此方法并未在此版本中试过。

赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《如何让phpStudy2018 Nginx 支持WordPress自定义链接?》
文章链接:https://www.ibytx.com/2374.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

登录

找回密码

注册