https nginx phpstudy_让phpStudy2018 Nginx 支持WordPress自定义链接

只适合Windows本地环境(服务器上没试过),默认phpStudy2018 Nginx并不支持WordPress自定义链接,可以通过修改配置文件支持让其支持。

让phpStudy2018 Nginx 支持WordPress自定义链接

用文本编辑工具打开PHPTutorial\nginx\conf目录的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程序直接安装在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,此方法并未在此版本中试过。

方法来自网络

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值