Home > CMS Tutorial > WordPress > Let phpStudy2018 Nginx support WordPress custom links

Let phpStudy2018 Nginx support WordPress custom links

藏色散人
Release: 2019-10-26 13:51:16
forward
2426 people have browsed it

下面由WordPress教程栏目给大家介绍让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;
        }
Copy after login

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

一、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;
}
Copy after login

二、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;
}
Copy after login

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

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

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

可以到官网下载适合的版本:https://www.xp.cn/download.html

The above is the detailed content of Let phpStudy2018 Nginx support WordPress custom links. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:zmingcx.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template