By using this site, you agree to the Privacy Policy and Terms of Use.
接受
智诚云集
  • 首页
  • 互联网
  • 分享
  • 记录
  • 互联网
    • Blog Index
    • Search Page
    • 404 Page
  • 联系
阅读: WordPress 伪静态规则设置:Apache和Nginx,以及二级目录规则
SUBSCRIBE
智诚云集智诚云集
Font ResizerAa
  • 云服务器推荐
  • 腾讯云
  • 阿里云
  • 京东云
Search
  • Home
  • Home
  • Blog
  • Blog
  • Categories
    • Technology
    • Travel
    • Lifestyle
    • Market
    • Innovate
    • Insurance
  • Categories
    • Technology
    • Travel
    • Lifestyle
    • Market
    • Innovate
    • Insurance
  • Bookmarks
  • Bookmarks
  • More Foxiz
    • Blog Index
    • Sitemap
  • More Foxiz
    • Blog Index
    • Sitemap
  • Contact
  • Contact
Have an existing account? 登录
关注我们
© Foxiz News Network. Ruby Design Company. All Rights Reserved.
记录

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

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

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;
}
}
标签:AllowOverride allapachehtaccesshttpd.confNginxWordPress伪静态
分享这篇文章
Facebook Email Copy Link Print
By智诚云集 - Xyok.Cn
关注:
分销:阿里云、腾讯云、百度云、GoDaddy、景安云、Linode云服务器产品。
上一篇 WordPress 5.3 beta3 测试版本百度网盘下载
下一篇 吐槽顺丰速运(SF Holding)快递行业的职责呢?

You Might Also Like

记录

WordPress配置注册邮件发送SMTP方法 非插件版

默认大部分主机空间都…

8 Min Read
记录

5·12汶川特大地震 逝者安息

5·12汶川地震(t…

4 Min Read

密码保护:关于我的故事(待续)

此内容受密码保护。如…

14 Min Read
记录

360家庭防火墙路由器浏览网站报毒&非法网页解决方法

在使用360路由器场…

4 Min Read
智诚云集智诚云集
关注我们
© Foxiz News Network. Ruby Design Company. All Rights Reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?