User-Profile-Image
hankin
  • 5
  • 关于
  • 分类
    • 路由器
    • 电脑相关
    • 游戏相关
    • 未分类
    • 服务器相关
    • 数据库
  • 页面
    • 关于
  • 友链
    • 华夏网盟
Help?

Please contact us on our email for need any support

Support
  • 关于
    首页   ›   服务器相关   ›   正文
服务器相关

Typecho去掉index.php让链接更美观

2021-02-24 09:10:14
135  0 0

Typecho建立后访问会在域名后加上index.php,很多人都接受不了

更改前是这样的:http://xxx/index.php/archives/1/

更改后是这样的:http://xxx/1.html

开始设置

打开设置 / 永久链接,改成如下图所示

这时会提醒你“重写功能检测失败,请检查你的服务器设置” 不用理会继续开启,然后保存设置

1.png

按照以上设置,文章链接会是数字,比如:/1.html

而分类页和独立页面会是缩阅名,而缩阅名可以自己设置,比如:/ss.html

注意:现在打开你的博客文章会出现404错误

然后我们需要修改nginx配置规则

如果使用的是宝塔面板,就在 网站-设置-配置文件 里面修改

在规则里加入以下代码后保存

NGINX伪静态:

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

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>

以宝塔面板为例:
3.png

至此,大功告成,访问前端页面试试吧。

评论 (0)

Click here to cancel reply.

欢迎您 游客  

近期文章

  • 用于网速测试的下载测速文件合集
  • docker构建SB镜像
  • pterodactl docker install
  • OpenWRT流量实时监控插件
  • docker部署dify

近期评论

No comments to show.

归档

  • 1 月 2026
  • 8 月 2025
  • 5 月 2025
  • 4 月 2025
  • 3 月 2025
  • 2 月 2025
  • 12 月 2024
  • 4 月 2024
  • 10 月 2023
  • 8 月 2023
  • 4 月 2023
  • 3 月 2023
  • 2 月 2023
  • 10 月 2021
  • 5 月 2021
  • 3 月 2021
  • 2 月 2021

分类

  • 数据库
  • 服务器相关
  • 未分类
  • 游戏相关
  • 电脑相关
  • 路由器
Copyright © 2026
smarty_hankin 主题. Designed by hankin
主页
页面
  • 关于
博主
hkthomas 管理员
136 文章 0 评论 18310 浏览
测试
测试