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

简介:

[摘要]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

相关文章
|
10天前
|
消息中间件 监控 数据可视化
Apache Airflow 开源最顶级的分布式工作流平台
Apache Airflow 是一个用于创作、调度和监控工作流的平台,通过将工作流定义为代码,实现更好的可维护性和协作性。Airflow 使用有向无环图(DAG)定义任务,支持动态生成、扩展和优雅的管道设计。其丰富的命令行工具和用户界面使得任务管理和监控更加便捷。适用于静态和缓慢变化的工作流,常用于数据处理。
Apache Airflow 开源最顶级的分布式工作流平台
|
14天前
|
存储 SQL Apache
Apache Doris 开源最顶级基于MPP架构的高性能实时分析数据库
Apache Doris 是一个基于 MPP 架构的高性能实时分析数据库,以其极高的速度和易用性著称。它支持高并发点查询和复杂分析场景,适用于报表分析、即席查询、数据仓库和数据湖查询加速等。最新发布的 2.0.2 版本在性能、稳定性和多租户支持方面有显著提升。社区活跃,已广泛应用于电商、广告、用户行为分析等领域。
Apache Doris 开源最顶级基于MPP架构的高性能实时分析数据库
|
1月前
|
缓存 前端开发 应用服务中间件
CORS跨域+Nginx配置、Apache配置
CORS跨域+Nginx配置、Apache配置
134 7
|
1月前
|
存储 应用服务中间件 PHP
设置nginx中文件上传的大小限制度
设置nginx中文件上传的大小限制度
|
1月前
|
应用服务中间件 nginx
nginx反向代理与证书设置
nginx反向代理与证书设置
40 3
|
2月前
|
Ubuntu 应用服务中间件 数据库
Nginx配置:阻止非国内IP地址访问的设置方法
此外,出于用户隐私和法律合规性的考虑,应慎重考虑阻止特定国家或地区IP地址的决策。在某些情况下,这可能被视为歧视性或违反当地法律。
147 2
|
3月前
|
Ubuntu 应用服务中间件 Linux
在Linux中,如何配置Web服务器(如Apache或Nginx)?
在Linux中,如何配置Web服务器(如Apache或Nginx)?
|
3月前
|
缓存 负载均衡 应用服务中间件
Nginx 代理管理器强势登场!轻松设置反向代理,为你的网络安全与高效护航,快来探索!
【8月更文挑战第23天】Nginx 代理管理器(NPM)是一款强大的工具,用于简化反向代理的设置流程。反向代理能隐藏后端服务器的真实IP,提升安全性,实现负载均衡与缓存等功能。用户需先安装Nginx 代理管理器,然后通过其Web界面添加代理主机,指定代理名称、协议类型、服务器地址及端口等信息。对于HTTPS协议,还需上传SSL证书/密钥。完成设置后,可通过浏览器测试反向代理是否正常工作。Nginx 代理管理器还支持高级特性,如负载均衡、缓存及访问控制等。
101 1
|
3月前
|
Web App开发 应用服务中间件 网络安全
如何在 Apache 和 Nginx 上配置 OCSP Stapling
如何在 Apache 和 Nginx 上配置 OCSP Stapling
95 8
|
4月前
|
负载均衡 应用服务中间件 网络安全