By using this site, you agree to the Privacy Policy and Terms of Use.
接受
智诚云集
  • 首页
  • 互联网
  • 分享
  • 记录
  • 互联网
    • 社会
    • 网文
    • 站推荐
    • 网络用语
    • 贵金属
  • 帮助%Help
    • Blog Index
    • Discuz
    • WordPress
  • Contact
正在阅读: WordPress 伪静态规则设置:Apache 和 Nginx,以及二级目录规则
Xyok Gather

智诚云集

WordPress|Discuz|ThinkPHP|SEO 优化|推广营销|中小企业网站建设服务 - Xyok Gather

字体大小调整Aa
  • - Recommend -
  • [腾讯云]99 元/年
  • [阿里云]38 元/年
  • [京东云]49 元/年
  • [七牛云]CDN/10G
Search
  • Home
  • Blog
  • Categories
    • Technology
    • Travel
    • Lifestyle
    • Market
    • Innovate
    • Insurance
  • Bookmarks
  • More Foxiz
    • Blog Index
    • Sitemap
  • Contact
已有账户? 登录
关注我们
  • Home
  • World
  • Market
  • Contact
  • Blog
© Foxiz News Network. Ruby Design Company. All Rights Reserved.
记录

WordPress 伪静态规则设置:Apache 和 Nginx,以及二级目录规则

智诚云集 - Xyok.Cn
最后更新: 2025 年 12 月 6 日 下午 9:33
智诚云集 - Xyok.Cn
8 分钟阅读
分享
分享

WordPress 的伪静态规则是根据服务器环境来设置的,不同的 PHP 环境有不同的伪静态设置方法,常见的 PHP 环境有 Apache 和 Nginx 。

Apache 规则:

首先要开启 apache 的 url_rewrite 模块 (一般默认都是开启的),也就是在 httpd.conf 中去掉这句话的注释 LoadModule rewrite_module modules/mod_rewrite.so,httpd.conf 中找到 AllowOverride,把 AllowOverride None 修改成 AllowOverride all

网站根目录下要有 .htaccess 文件,然后将下面的代码复制进去。


    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

上方规则前加上: ,结尾
WordPress 在 Apache 环境下二级目录建站伪静态操作方式同上。

Nginx 规则:

操作方法:以下代码加入到网站的配置文件 xxxx.conf 中的 server{} 中。

根目录下 WordPress 的伪静态规则:


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;
}
}

二级目录下 WordPress 的伪静态规则:

注意将以下代码中的 「二级目录名」 换成自己的真实二级目录名。


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;
}
}
- Open WeChat to follow -
Ad image
标签:AllowOverride allapachehtaccesshttpd.confNginxWordPress伪静态
分享本文
电子邮件 复制链接 打印
作者智诚云集 - Xyok.Cn
关注:
分销:阿里云、腾讯云、百度云、 GoDaddy 、景安云、 Linode 云服务器产品。
上一篇文章 WordPress 5.3 beta3 测试版本百度网盘下载
下一篇文章 吐槽顺丰速运 (SF Holding) 快递行业的职责呢?
- Open WeChat to follow -
Ad image
- Advertisement -
- Advertisement -
随机阅读
解决电脑提示 U 盘需要格式化
记录
高德地图 app"我要报警"快速上报具体位置
分享
阿里云边缘安全加速 ESA 免费版 0 元续费几十年
分享
拼多多多店铺同款打折优惠到底有多离谱?
记录
[奇葩一说] 网购台式电脑需要通电才可以使用?
社会
第十二个南京大屠杀遇难者公祭日 勿忘国殇 砥砺前行
记录

精选阅读·Selected readings

记录

2019 年南京大屠杀死难者国家公祭日 吾辈自强 勿忘国耻

0 分钟阅读
记录

助力全国中小企业官网建设 300 元/年拥有电脑和手机官网

由智诚云集&…

7 分钟阅读
Wordpress

免插件 WordPress 底部添加网站运行时间

今天有位 QQ 好友问 W…

8 分钟阅读
记录

linux 系统 php 安装 openssl 扩展

1 、我的源码在 /h…

6 分钟阅读
Copyright © 2026 · 智诚云集 · 技术支持 Xyok Gather.
苏 ICP 备 11081889 号-3 苏公网安备 32038102000146 号 Xyok Gather
Welcome Back!

Sign in to your account

用户名或电子邮件地址
密码

忘记密码?