PbootCMS 伪静态配置与规则详解

伪静态简介

标签作用 适用版本 说明
URL美化 2.X、3.X 配置伪静态后,URL 中不再包含兼容模式的问号,地址更美观,便于推广优化。

1. IIS7+ 环境

步骤 操作内容 说明
1 安装 rewrite 组件 如果使用空间,一般空间商默认已安装。
2 后台开启伪静态开关 进入后台配置参数,开启伪静态功能。
3 创建 web.config 文件 规则内容如下:<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                 <rule name="reIndex" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="true" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?p={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

2. Apache 环境

步骤 操作内容 说明
1 开启 Apache 重写模块 具体操作可百度,如果使用空间,一般空间商默认已开启。
2 后台开启伪静态开关 进入后台配置参数,开启伪静态功能。
3 创建 .htaccess 文件

规则内容如下:

apache

<IfModule mod_rewrite.c>

Options +FollowSymlinks<br> RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php?p=$1 [QSA,PT,L]

</IfModule>


3. Nginx 环境

步骤 操作内容 说明
1 后台开启伪静态开关 进入后台配置参数,开启伪静态功能。
2 修改 Nginx 虚拟主机配置

在 location / {} 中添加以下规则:

nginx<br>location / 

if (!-e $request_filename){

rewrite ^/index.php(.*)$ /index.php?p=$1 last;

rewrite ^(.*)$ /index.php?s=$1 last;

}


注意事项

注意事项 说明
空间环境差异 不同服务器环境(IIS、Apache、Nginx)需根据实际情况调整伪静态规则。
后台开关 必须在后台开启伪静态开关,否则规则无效。
文件权限 确保配置文件(如 web.config 或 .htaccess)具有正确的读取权限。
测试验证 配置完成后,建议访问网站测试伪静态是否生效。
posted @ 2025-12-02 09:40  Henry王  阅读(0)  评论(0)    收藏  举报