小编给大家分享一下phpStudy2018 Nginx如何实现支持WordPress自定义链接的方法,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
只适合Windows本地环境(服务器上没试过),默认phpStudy2018 Nginx并不支持WordPress自定义链接,可以通过修改配置文件支持让其支持。
用文本编辑工具打开PHPTutorial\nginx\conf目录的nginx.conf文件,修改前做个备份,以免修改失误,造成phpStudy无法启动。
搜索autoindex on,找到类似:
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程序直接安装在PHPTutorial\WWW目录中:
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程序安装在PHPTutorial\WWW子目录中,比如: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,此方法并未在此版本中试过。
以上是phpStudy2018 Nginx如何实现支持WordPress自定义链接的方法的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。