Typecho后台设置永久链接后,会在域名后加上index.php,很多人都接受不了。例如如下网址:https://www.jichun29.cn/index.php/archives/37/,但我们希望最终的形式是这样:https://www.jichun29.cn/archives/37.html。那么我们如何做到这样的效果?

1.配置服务器的rewrite规则
如果在保存上述配置的时候,typecho无法自动配置,那么你可能需要手动配置服务器的rewrite规则。

Linux Apache 环境 (.htaccess)

<IfModule mod_rewrite.c>
RewriteEngine On
# 下面是在根目录,文件夹要修改路径
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

Linux Apache 环境(Nginx)

location / {
index index.html index.php;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php) {
rewrite (.*) $1/index.php;
}
if (!-f $request_filename) {
rewrite (.*) /index.php;
}
}

Windows IIS 伪静态 (httpd.ini)

[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# 中文tag解决
RewriteRule /tag/(.*) /index\.php\?tag=$1
# sitemapxml
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# 内容页
RewriteRule /(.*).html /index.php/$1.html [L]
# 评论
RewriteRule /(.*)/comment /index.php/$1/comment [L]
# 分类页
RewriteRule /category/(.*) /index.php/category/$1 [L]
# 分页
RewriteRule /page/(.*) /index.php/page/$1 [L]
# 搜索页
RewriteRule /search/(.*) /index.php/search/$1 [L]
# feed
RewriteRule /feed/(.*) /index.php/feed/$1 [L]
# 日期归档
RewriteRule /2(.*) /index.php/2$1 [L]
# 上传图片等
RewriteRule /action(.*) /index.php/action$1 [L]

nginx 配置

    server {
listen 80;
server_name yourdomain.com;
root /home/yourdomain/www/;
index index.html index.htm index.php; if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
} location ~ .*\.php(\/.*)*$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
} access_log logs/yourdomain.log combined;
}

apache 配置

    <IfModule mod_rewrite.c>
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] </IfModule>

2.后台配置typecho伪静态
如图,在typecho后台,开启伪静态,并选择你喜好的url形式
具体操作,根据本人实际操作如下

我的虚拟主机是apache的,在网站根目录找到.htaccess,有的没有可能是设置了隐藏文件,显示隐藏文件就能看到了。
然后编辑.htaccess文件,加入上文中对应的apache配置代码保存。然后去typecho程序后台,设置>永久链接,按照上文中图片的设置,保存即可。

Typecho如何去掉/隐藏index.php的更多相关文章

  1. CI 框架怎么去掉隐藏入口文件 index.php

    当我重新接触一个框架的时候首先肯定要去掉入口文件,也就是index.php 这个东西在url上很不漂亮,而且每次我访问我的网站的时候都要打进去url里面.这样告诉一个去掉 CI框架里面入口文件的方法, ...

  2. ThinkPHP路由去掉隐藏URL中的index.php

    官方默认的.htaccess文件 <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On ...

  3. CI 框架隐藏index.php-ubuntu

    和朋友在做一个小网站,用到了CI框架,之前测试都是在windows上,隐藏index.php也相对比较简单.但服务器是ubuntu系统,需要配置一下,根据网上看到的一些教程,结合自己电脑的特点,记录步 ...

  4. ThinkPHP CI codeignitor 框架 apache 重写 url 隐藏index.php 服务器 报错:Object not found! 可能是.htaccess隐藏index.php

    隐藏index.php可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则.以Apache为例,需要在入口文件的同级添加.htaccess文件(官方默认自带了该文 ...

  5. yii框架 隐藏index.php 以及美化URL(pathinfo模式访问)

    首先我们分步骤来: 安装好 yii 以后  我们看到的url地址如下所示: http://www.3w.com/MyApp/backend/web/index.php?r=site%2Flogin 我 ...

  6. ThinkPHP5 隐藏index.php问题

    隐藏index.php 可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则. 以Apache为例,需要在入口文件的同级添加.htaccess文件(官方默认自带了 ...

  7. Yii Framework隐藏index.php文件的步骤

    Yii Framework隐藏index.php文件的步骤 作者:feebas 发布于:2012-4-23 13:36 Monday 分类:Yii Framework 1.开启apache的mod_r ...

  8. url优化|隐藏index.php

    隐藏index.php   一.codeigniter codeigniter和许多php框架一样,有个单一入口index.php,从url上看,显得很不友好.通过apache的rewirte,是可以 ...

  9. Yii2.0简单隐藏index.php文件和模块配置和layout布局配置禁用和日志写入配置

    隐藏index.php文件 目的:想去掉浏览器地址栏中的 index.php?r= 这一块. 在/config/web.php中   ’components'=>[]   中添加如下代码: 'u ...

  10. thinkphp中redirect重定向后隐藏index.php

    首先,.htaccess文件要配置好隐藏index.php.系统默认生成的就行. 然后,也是最关键的一部,要在Application/Home/Conf里的config.php文件中增加如下配置: & ...

随机推荐

  1. Java 设计模式——从冰雪经济看设计模式的综合运用(工厂、单例、策略、观察者)

    当冬季的寒风拂过大地,冰雪经济如同一颗璀璨的明珠,在寒冷中散发着炽热的魅力.滑雪场.冰雕展.冰雪主题酒店等各类冰雪产业蓬勃发展,其背后的运营逻辑和策略,与 Java 设计模式有着奇妙的相似之处,为我们 ...

  2. VS C++ 出现debug assertion failed弹框,怎么定位代码

    当VS C++ 出现debug assertion failed弹框时,想定位代码,但是按弹框出现的3个按钮都不能定位代码,这个时候,你需要打开VS界面,暂停调试,然后打开函数调用栈,找到最后执行的函 ...

  3. VTK 平面裁剪

    有些时候需要显示零件内部情况,所有会对零件显示进行平面裁剪,这里用到了vtkPlane和vtkClipPolyData. vtkPlane是定义一个平面,vtkClipPolyData使用vtkPla ...

  4. SpringBoot 整合Swagger2 踩坑记录

    SpringBoot 整合Swagger2 踩坑记录 Failed to start bean 'documentationPluginsBootstrapper'; nested exception ...

  5. dockerfile实现tomcat以及java的war包自动部署

    1. 下载jdk和tomcat wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.93/bin/apache-tomcat-8.5.93.tar.g ...

  6. 反微服务架构(A Macro Services Framework)

    作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢! cnblogs博客 zhihu Github 公众号:一本正经的瞎扯 反微服务架构(A Macro Services Frame ...

  7. 【Python】HTML中Base64存储的图片转为本地图片文件

    我用jupyter notebook写了笔记之后,想导出markdown,然后导出不了,我就只能导出html,结果导出的html存储图片用的base64的方式-- 于是我就要把导出的html文档里面的 ...

  8. 【Vue】vue项目搭建、ES6的简单使用(大觅)

    目录 项目搭建与基本配置 项目搭建 安装淘宝NPM镜像 cnpm 安装webpack 新建项目 运行项目 运行时出现的一些问题和解决方案 框架安装 安装UI框架iView 引入UI框架iView 引入 ...

  9. ERROR: SSL peer shut down incorrectly错误解决(Android Studio)

    错误信息:ERROR: SSL peer shut down incorrectly错误解决(Android Studio) 错误原因:android studio在下载"gradle-4. ...

  10. 万字长文:手把手教你实现一套高效的IM长连接自适应心跳保活机制

    本文作者"Carson",现就职于腾讯公司,原题"高效保活长连接:手把手教你实现自适应的心跳保活机制",有较多修订和改动. 1.引言 当要实现IM即时通讯聊天. ...