当前位置: 首页 > 工具软件 > Tipask > 使用案例 >

开源问答Tipask伪静态apache和nginx设置

慕容成和
2023-12-01

[摘要]Tipask是一款开源、SEO友好、扩展性强、性能卓越的问答系统!Tipask 独特的MVC构架,使得二次开发非常容易,多种接口方便和已有系统整合。本文介绍开源问答Tipask伪静态apache和nginx设置。

  第一步:登录tipask后台,seo设置,开启伪静态

  第二步:在Nginx的配置文件nginx.conf 中,加入以下代码实现rewrite。若开启所有规则,则添加如下代码:

tipask安装在web的根目录下的情况

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

tipask不在web的根目录下的情况

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

  修改以上下语句中的 /tipask 为你的Tipask目录地址即可

第三步:重启nginx,完毕

这个是apache下的rewrite规则

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

  创建.htaccess这个文件,放到tipask根目录即可,然后后台开启伪静态!.htaccess内容如下:


       [ISAPI_Rewrite]

        # 3600 = 1 hour

        CacheClockRate 3600


        RepeatLimit 32


        RewriteRule ^(.*)/index/default\.html$ $1/index\.php\?index/default.html

        RewriteRule ^(.*)/index\.html$ $1/index\.php\?index/default.html

        RewriteRule ^(.*)/.html$ $1/index\.php\?index/default.html

        RewriteRule ^(.*)/category/view/all\.html$ $1/index\.php\?category/view/all.html

        RewriteRule ^(.*)/c-all\.html$ $1/index\.php\?category/view/all.html

        RewriteRule ^(.*)/c-all/all\.html$ $1/index\.php\?category/view/all.html

        RewriteRule ^(.*)/expert/default\.html$ $1/index\.php\?expert/default.html

        RewriteRule ^(.*)/user/activelist\.html$ $1/index\.php\?user/activelist.html

        RewriteRule ^(.*)/topic/default\.html$ $1/index\.php\?topic/default.html

        RewriteRule ^(.*)/gift/default\.html$ $1/index\.php\?gift/default.html

        RewriteRule ^(.*)/index/help\.html$ $1/index\.php\?index/help.html

        RewriteRule ^(.*)/index/ajaxchkimg\.html$ $1/index\.php\?index/ajaxchkimg.html


        RewriteRule ^(.*)/question/add\.html$ $1/index\.php\?question/add.html

        RewriteRule ^(.*)/question/answer\.html$ $1/index\.php\?question/answer.html

        RewriteRule ^(.*)/question/add/([0-9]+)\.html$ $1/index\.php\?question/add/$2.html

        RewriteRule ^(.*)/question/edit.html$ $1/index\.php\?question/edit.html

        RewriteRule ^(.*)/question/edittag.html$ $1/index\.php\?question/edittag.html

        RewriteRule ^(.*)/question/movecategory.html$ $1/index\.php\?question/movecategory.html

        RewriteRule ^(.*)/question/close/([0-9]+)\.html$ $1/index\.php\?question/close/$2.html

        RewriteRule ^(.*)/question/edit/([0-9]+)\.html$ $1/index\.php\?question/edit/$2.html

        RewriteRule ^(.*)/question/editanswer.html$ $1/index\.php\?question/editanswer.html

        RewriteRule ^(.*)/question/editanswer/([0-9]+)\.html$ $1/index\.php\?question/editanswer/$2.html

        RewriteRule ^(.*)/question/editanswer/([0-9]+)/([0-9]+)\.html$ $1/index\.php\?question/editanswer/$2/$3.html

        RewriteRule ^(.*)/question/delete/([0-9]+)\.html$ $1/index\.php\?question/delete/$2.html

        RewriteRule ^(.*)/question/adopt\.html$ $1/index\.php\?question/adopt.html

        RewriteRule ^(.*)/question/supply\.html$ $1/index\.php\?question/supply.html

        RewriteRule ^(.*)/question/supply/([0-9]+)\.html$ $1/index\.php\?question/supply/$2.html

        RewriteRule ^(.*)/question/appendanswer/([0-9]+)/([0-9]+)\.html$ $1/index\.php\?question/appendanswer/$2/$3.html

        RewriteRule ^(.*)/question/search\.html$ $1/index\.php\?question/search.html

        RewriteRule ^(.*)/question/search/(.*)\.html$ $1/index\.php\?question/search/$2.html

        RewriteRule ^(.*)/question/search/(.*)/([0-9]+)\.html$ $1/index\.php\?question/search/$2/$3.html

        RewriteRule ^(.*)/question/search/tag:(.*)\.html$ $1/index\.php\?question/search/tag:$2.html

        RewriteRule ^(.*)/answer/addcomment\.html$ $1/index\.php\?answer/addcomment.html

        RewriteRule ^(.*)/answer/deletecomment\.html$ $1/index\.php\?answer/deletecomment.html


        RewriteRule ^(.*)/note/list\.html$ $1/index\.php\?note/list.html

        RewriteRule ^(.*)/note/list/([0-9]+)\.html$ $1/index\.php\?note/list/$2.html

        RewriteRule ^(.*)/note/view/([0-9]+)\.html$ $1/index\.php\?note/view/$2.html


        RewriteRule ^(.*)/c-([0-9]+)\.html$ $1/index\.php\?category/view/$2.html

        RewriteRule ^(.*)/l-([0-9]+)\.html$ $1/index\.php\?category/list/$2.html

        RewriteRule ^(.*)/r-([0-9]+)\.html$ $1/index\.php\?category/recommend/$2.html

        RewriteRule ^(.*)/q-([0-9]+)\.html$ $1/index\.php\?question/view/$2.html

        RewriteRule ^(.*)/u-([0-9]+)\.html$ $1/index\.php\?user/space/$2.html

        RewriteRule ^(.*)/us-([0-9]+)\.html$ $1/index\.php\?user/scorelist/$2.html

        RewriteRule ^(.*)/c-([0-9]+)/([0-9]+)\.html$ $1/index\.php\?c-$2/$3.html

        RewriteRule ^(.*)/c-all/([0-9]+)\.html$ $1/index\.php\?c-all/$2.html

        RewriteRule ^(.*)/c-([0-9]+)/all/([0-9]+)\.html$ $1/index\.php\?c-$2/all/$3.html

        RewriteRule ^(.*)/c-all/all/([0-9]+)\.html$ $1/index\.php\?c-all/all/$2.html

        RewriteRule ^(.*)/c-([0-9]+)/all\.html$ $1/index\.php\?c-$2/all\.html

        RewriteRule ^(.*)/c-all/([0-9]+)/([0-9]+)\.html$ $1/index\.php\?c-all/$2/$3.html

        RewriteRule ^(.*)/c-([0-9]+)/([0-9]+)/([0-9]+)\.html$ $1/index\.php\?c-$2/$3/$4.html

        RewriteRule ^(.*)/c-([0-9]+)/([0-9]+)\.html$ $1/index\.php\?c-$2/$3.html

        RewriteRule ^(.*)/l-([0-9]+)/([0-9]+)\.html$ $1/index\.php\?l-$2/$3.html

        RewriteRule ^(.*)/u-([0-9]+)\.html$ $1/index\.php\?u-$2.html

        RewriteRule ^(.*)/r-([0-9]+)\.html$ $1/index\.php\?r-$2.html


        RewriteRule ^(.*)/user/code\.html$ $1/index\.php\?user/code.html

        RewriteRule ^(.*)/user/register\.html$ $1/index\.php\?user/register.html

        RewriteRule ^(.*)/user/default\.html$ $1/index\.php\?user/default.html

        RewriteRule ^(.*)/user/score\.html$ $1/index\.php\?user/score.html

        RewriteRule ^(.*)/user/level\.html$ $1/index\.php\?user/level.html

        RewriteRule ^(.*)/user/profile\.html$ $1/index\.php\?user/profile.html

        RewriteRule ^(.*)/user/uppass\.html$ $1/index\.php\?user/uppass.html

        RewriteRule ^(.*)/user/editimg\.html$ $1/index\.php\?user/editimg.html

        RewriteRule ^(.*)/user/mycategory\.html$ $1/index\.php\?user/mycategory.html

        RewriteRule ^(.*)/message/personal\.html$ $1/index\.php\?message/personal.html

        RewriteRule ^(.*)/message/system\.html$ $1/index\.php\?message/system.html

        RewriteRule ^(.*)/message/send\.html$ $1/index\.php\?message/send.html

        RewriteRule ^(.*)/message/send/([0-9]+)\.html$ $1/index\.php\?message/send/$2.html

        RewriteRule ^(.*)/message/view/system/([0-9]+)\.html$ $1/index\.php\?message/view/system/$2.html

        RewriteRule ^(.*)/message/view/personal/([0-9]+)\.html$ $1/index\.php\?message/view/personal/$2.html

        RewriteRule ^(.*)/user/ask/([0-9]+)\.html$ $1/index\.php\?user/ask/$2.html

        RewriteRule ^(.*)/user/ask/([0-9]+)/([0-9]+)\.html$ $1/index\.php\?user/ask/$2/$3.html

        RewriteRule ^(.*)/user/space_ask/([0-9]+)\.html$ $1/index\.php\?user/space_ask/$2.html

        RewriteRule ^(.*)/user/space_ask/([0-9]+)/([0-9]+)\.html$ $1/index\.php\?user/space_ask/$2/$3.html

        RewriteRule ^(.*)/user/space_ask/([0-9]+)/all/([0-9]+)\.html$ $1/index\.php\?user/space_ask/$2/all/$3.html

        RewriteRule ^(.*)/user/answer/([0-9]+)\.html$ $1/index\.php\?user/answer/$2.html

        RewriteRule ^(.*)/user/answer/([0-9]+)/([0-9]+)\.html$ $1/index\.php\?user/answer/$2/$3.html

        RewriteRule ^(.*)/user/space_answer/([0-9]+)\.html$ $1/index\.php\?user/space_answer/$2.html

        RewriteRule ^(.*)/user/space_answer/([0-9]+)/([0-9]+)\.html$ $1/index\.php\?user/space_answer/$2/$3.html

        RewriteRule ^(.*)/user/space_answer/([0-9]+)/all/([0-9]+)\.html$ $1/index\.php\?user/space_answer/$2/all/$3.html

        RewriteRule ^(.*)/user/activelist/([0-9]+)\.html$ $1/index\.php\?user/activelist/$2.html

        RewriteRule ^(.*)/favorite/default\.html$ $1/index\.php\?favorite/default.html

        RewriteRule ^(.*)/user/login\.html\?*(.*)$ $1/index\.php\?user/login.html

        RewriteRule ^(.*)/user/logout\.html\?*(.*)$ $1/index\.php\?user/logout.html

本文转自奔跑在路上博客51CTO博客,原文链接http://blog.51cto.com/qiangsh/1591346如需转载请自行联系原作者


qianghong000

 类似资料: