WordPress – PhpStudy本地环境修改固定链接打不开网页404错误
本文作者:StubbornHuang
版权声明:本文为站长原创文章,如果转载请注明原文链接!
原文标题:WordPress – PhpStudy本地环境修改固定链接打不开网页404错误
原文链接:https://www.stubbornhuang.com/626/
发布于:2020年01月08日 16:53:07
修改于:2020年01月09日 14:22:25

1 问题
PhpStudy本地测试wordPress,在后台修改固定链接方式之后出现了网页打不开的问题,直接404
2 解决方法
修改配置文件vhosts.conf文件,如下图
在该文件location处加入以下代码:
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;
}
修改后整个vhosts.conf配置文件内容如下:
server {
listen 80;
server_name localhost;
root "D:/Program Files (x86)/PhpStudy/phpstudy_pro/WWW";
location / {
index index.php index.html;
error_page 400 /error/400.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 500 /error/500.html;
error_page 501 /error/501.html;
error_page 502 /error/502.html;
error_page 503 /error/503.html;
error_page 504 /error/504.html;
error_page 505 /error/505.html;
error_page 506 /error/506.html;
error_page 507 /error/507.html;
error_page 509 /error/509.html;
error_page 510 /error/510.html;
autoindex off;
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;
}
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
修改之后保存,在phpstudy重启nginx或者即可。
当前分类随机文章推荐
- WordPress - WordPress升级5.8之后获取最新评论的代码失效问题解决 阅读1330次,点赞0次
- WordPress - get_header函数,加载主题头部header模板 阅读741次,点赞0次
- WordPress - 为文章增加评论才可查看相关隐藏内容的代码 阅读2424次,点赞3次
- WordPress - Windows使用PhpStudy本地部署WordPress 阅读3494次,点赞0次
- WordPress - 用户修改密码/邮箱时禁止向管理员/用户发送通知邮件 阅读658次,点赞0次
- WordPress - 插件OSS Upload与WP Editor.md/WP Githuber MD插件冲突,导致katex公式不正确显示的问题 阅读3007次,点赞0次
- WordPress - 禁用XML-RPC接口,禁止访问xmlrpc.php,避免DDOS攻击,防止暴力破解 阅读2606次,点赞0次
- WordPress - get_footer函数,加载主题底部页脚footer模板 阅读679次,点赞0次
- WordPress - 支持用户注册时使用中文名 阅读1764次,点赞0次
- WordPress - PhpStudy本地环境修改固定链接打不开网页404错误 阅读4151次,点赞1次
全站随机文章推荐
- Duilib - 使Duilib主窗口前置,但是又不是一直作为最顶层窗口 阅读2775次,点赞2次
- 资源分享 - Vulkan Cookbook - Work through recipes to unlock the full potential of the next generation graphics API-Vulkan 英文高清PDF下载 阅读1932次,点赞0次
- 左手坐标系与右手坐标系 阅读2915次,点赞0次
- TortoiseGit - 本地仓库更改远程仓库URL 阅读543次,点赞0次
- 资源分享 - The Algorithms and Principles of Non-photorealistic Graphics - Artistic Rendering and Cartoon Animation 英文高清PDF下载 阅读1212次,点赞0次
- 资源分享 - Non-Photorealistic Rendering 英文高清PDF下载 阅读1372次,点赞0次
- VPS - 使用XShell连接VPS 阅读3037次,点赞0次
- WordPress - 插件WP Editor.md 在网站更换为https后无法正确加载 阅读3816次,点赞0次
- 资源分享 - GPU Gems 3英文高清PDF下载 阅读2931次,点赞0次
- 资源分享 - 交互式计算机图形学:基于WebGL的自顶向下方法(第七版),Interactive Computer Graphics - A top-down approach with WebGL(Seven 7th Edition)中文版PDF下载 阅读172次,点赞0次
评论
164