zblog php版本实现URL静态化(伪静态)方法

2025-09-30 12:25:35

1、Step 1:首先去zblog后台的“应用中心”中下载安装下“静态管理中心”插件,zblog php版本默认是安装了“应用中心”的,可以直接去里面找,如果没有安装的话,就去官网里面下载就好。

2、Step 2:安装好“静态管理中心”插件以后,启动它。

3、Step 3:在“配置页面”的“静态化选项”中选择“伪静态”,然后可以设置下文章、页面、分类页等的URL配置,一般来说不修改默认就好了。然后单击“提交”按钮,自动跳转进入“ReWrite规则”。

4、Step 4:设置ReWrite规则。

(1)如果你的网站服务器是apache服务器,那么创建一个.htaccess文件,把下面的内容复制进去,然后将.htaccess文件上传到网站根目录下:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

(2)如果你的网站服务器是IIS7或者IIS8,那么创建一个web.config文件,把下面的内容复制进去,然后将web.config文件上传到网站根目录下:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

 <system.webServer>

  <rewrite>

   <rules>

    <rule name="/ Z-BlogPHP Imported Rule" stopProcessing="true">

     <match url="^.*?" ignoreCase="false" />

      <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/{R:0}" />

    </rule>

    <rule name="/ Z-BlogPHP Imported Rule index.php" stopProcessing="true">

     <match url="^index.php/.*?" ignoreCase="false" />

      <conditions logicalGrouping="MatchAll">

       <add input="{REQUEST_FILENAME}" matchType="IsFile" />

      </conditions>

     <action type="Rewrite" url="index.php/{R:0}" />

    </rule>

   </rules>

  </rewrite>

 </system.webServer>

</configuration>

(3)如果你的网站服务器是IIS6,那么创建一个httpd.ini文件,把下面的内容复制进去,然后将httpd.ini文件上传到网站根目录下:

[ISAPI_Rewrite]

RewriteRule /page_([0-9]*)\.html /index\.php\?page=$1&rewrite=1 [I,L]

RewriteRule /date-([0-9\-]+)(?:_)?([0-9]*)\.html /index\.php\?date=$1&page=$2&rewrite=1 [I,L]

RewriteRule /author-([0-9]+)(?:_)?([0-9]*)\.html /index\.php\?auth=$1&page=$2&rewrite=1 [I,L]

RewriteRule /tags-([0-9]+)(?:_)?([0-9]*)\.html /index\.php\?tags=$1&page=$2&rewrite=1 [I,L]

RewriteRule /category-([0-9]+)(?:_)?([0-9]*)\.html /index\.php\?cate=$1&page=$2&rewrite=1 [I,L]

RewriteRule /post/([0-9]+)\.html(\?.*)? /index\.php\?id=$1&rewrite=1 [I,L]

RewriteRule /([0-9]+)\.html(\?.*)? /index\.php\?id=$1&rewrite=1 [I,L]

5、Step 5:一般来说网站的服务器大多数都是apache或者是IIS,通过以上方法都是可以解决的。设置伪静态之前,一定要先确定服务器主机是否支持伪静态,如果不支持就要找主机商开通或者更换主机,如果支持,就要知道自己的服务器是apache还是IIS,之前我就误以为自己的主机是apache,然后老是弄不好,结果查看发现是IIS。如果不知道使用的是IIS的哪个版本,你可以两种方法都试下,应该会有一种是可以的。

6、Step 6:重新打开你的网站,你会发现已经成功伪静态了。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢