耿俭

Typecho开启伪静态与隐藏index.php方法
Typecho后台设置永久链接后,会在域名后加上index.php,很多人都接受不了。下面给大家介绍一下Typec...
扫描右侧二维码阅读全文
23
2019/06

Typecho开启伪静态与隐藏index.php方法

Typecho后台设置永久链接后,会在域名后加上index.php,很多人都接受不了。下面给大家介绍一下Typecho开启伪静态与隐藏index.php方法。

例如网址:https://www.gengjian.net/index.php/archives/1/

但我们希望最终的形式是这样https://www.gengjian.net/1.html

那么我们如何做到这样的效果?

第一步:后台配置typecho伪静态

如图,在typecho后台,开启伪静态,并选择你喜好的url形式:
Typecho开启伪静态.jpg

第二步:配置服务器的rewrite规则

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

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>

此配置可以放在apache的conf文件中,或者放在.htaccess中。

Typecho伪静态开启设置教程到这里就结束了,又需要的去试试吧。

最后修改:2019 年 06 月 23 日 03 : 22 PM

发表评论