Tipask是一款100%开放源码的PHP问答系统,基于Laravel5.6版本开发,容易扩展,具有强大的负载能力和稳定性。小编在迁移一个老旧的tipask问答网站时,发生了伪静态错误的故障,通过不断查找资料,终于总结出了可用的方法。

先说说伪静态后的效果。

文章页面 /q-10.html
栏目页面 /c-5.html
排行页面 /us-1.html
问题库页 /c-all.html
专题列表 /topic/default.html
用户页面 /u-1.html

旧版2.5 2.6 版本tipask问答Nginx伪静态规则设置方法:

if ($request_filename ~* (.*)\.html){
   rewrite ^/(.*)$  /index.php?$1; 
}

旧版tipask问答Apache伪静态规则设置方法:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^.*$ index.php?$0
</IfModule>

旧版tipask问答IIS伪静态规则设置方法:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
        <rewrite>
            <rules>
                <rule name="已导入的规则 1">
                    <match url="^.*$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?{R:0}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

新版 tipsask 3.5 Nginx 伪静态规则:

location / {  
	try_files $uri $uri/ /index.php$is_args$query_string;  
}