Typecho开启伪静态并隐藏index.php

2019-10-10

域名后加上index.php,让我异常难受。实在受不了
强迫我折腾,搞他!

环境

nginx version: openresty/1.15.8.2
PHP 5.4.16

步骤

https://www.abc.com/index.php/archives/37/
改后
https://www.abc.com/archives/37.html
直接上代码

server {
        listen          80;
        server_name     wcnm.ws;
        root            /home/wcnm/www/;
        index           index.html index.htm index.php;
#######################主要是这里#############################
        location / {
            root   html;
            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;
            }
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php$1 last;
            }
        }
##########################################################
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        access_log logs/yourdomain.log combined;
    }

重写功能检测失败, 请检查你的服务器设置
如果你仍然想启用此功能, 请勾选这里

打勾 并保存