一文解决全环境wordpress伪静态配置

WordPress默认为动态链接,wordpress提供了多种设置链接的选项,但有时它可能不会如您所愿。在本地wordpress网站中,有些后台服务软件需要开启支持wordpress伪静态,下面我们针对各种环境的wordpress站点一一阐述伪静态设置方式。

    Nginx伪静态设置

    据我们所知,现在大多数WordPress主题都在使用Nginx作为Web服务器。为Nginx添加伪静态设置非常简单,添加以下Nginx规则。

    location / {
    index index.php index.html index.htm;
    try_files $uri $uri/ /index.php?$args;
    }

    Apache 伪静态规则

    大多数Apache服务器支持使用.htaccess文件来设置wordpress伪静态。只要您的服务器支持.htaccess文件,WordPress在设置WordPress固定链接时会自动生成或更新这个文件,不需要太多设置,如果你的.htaccess没有自动生成,那么将以下代码添加到你的.htaccess文件中

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    IIS伪静态规则

    虽然现在用iis的来搭建php环境的比较少,但是为了少部分的用户,这里也将iis设置wordpress伪静态规则的代码放在下面以供使用

      <rewrite>
          <rules>
              <rule name="Main Rule" stopProcessing="true">
                  <match url=".*" />
                  <conditions logicalGrouping="MatchAll">
                      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                  </conditions>
                  <action type="Rewrite" url="index.php" />
              </rule>
          </rules>
      </rewrite>
      我爱主题网 自2012
      主题:260+ 销售:1000+
      兼容浏览器

      电话咨询

      7*12服务咨询电话:

      1855-626-3292

      微信咨询