【Typecho】 Typecho去掉 index.php

依然范儿特西
2021-06-08 / 0 评论 / 189 阅读 / 正在检测是否收录...

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

1. 配置服务器的 rewrite 规则

nginx

   server {
        listen          80;
        server_name     richerdyoung.com;
        root            /home/laofan/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/richerdyoung.com.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形式:

网站设置-》永久链接,选择启用地址重写功能

0

评论 (0)

取消