Typecho去掉index.php的方法与其他的网站程序去掉index.php的方式一样。都是借助web服务器软件的rewrite功能支持实现!

Tyoecho去掉网站所有页面链接中的index.php需要在typecho后台设置--永久链接设置--启用 是否使用地址重写功能。如果是apache环境,同时会默认在根目录生成相应的.htaccess文件,文件内容参考后面的内容。如果是nginx,需要人工设置一下规则!

96558-tmf5hxbw0wh.png
Apache下去掉index.php
需要在根目录下创建.htaccess

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

Nginx下去掉index.php
需要修改nginx配置文件,在对应网站的server中增加相应rewrite规则!

location / {

    if (!-e $request_filename) {
        rewrite  ^/(.*)$  /index.php/$1  last;
        break;
    }
}
Last modification:February 22, 2019
If you think my article is useful to you, please feel free to appreciate