ClassCMS

伪静态

如网站空间支持伪静态,则推荐开启伪静态,能使网址更加美观.

ClassCMS伪静态规则与常见程序(wordpress,thinkphp等)伪静态规则通用,如服务器已经有这些程序的伪静态规则,可以直接使用.

如需要手动开关伪静态,则请修改入口文件(默认为index.php)内$GLOBALS['C']['UrlRewrite'] 项,关闭伪静态后,后台地址将更改为 /index.php/admin

Apache伪静态(.htaccess):

RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]

Nginx伪静态(如不使用伪静态,则需开启pathinfo才能安装):

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

或者

location /{
    if (!-e $request_filename) {
       rewrite  ^(.*)$  /index.php/$1  last;
       break;
    }
}

Nginx子目录伪静态:

location /xxxx/ {
    index  index.php;
    autoindex  off;
    if (!-e $request_filename){
        rewrite  ^/xxxx/(.*)$  /xxxx/index.php/$1  last;
    }
}

IIS伪静态(web.config)

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="ClassCMS" stopProcessing="true">
                        <match url="^(.*)$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php" appendQueryString="true" />
                    </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

IIS子目录伪静态(web.config存放于网站根目录)

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="ClassCMS" stopProcessing="true">
                        <match url="^xxxx/(.*)$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="xxxx/index.php" appendQueryString="true" />
                    </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>