技术知识库

帮助中心 >  产品文档 >  网站相关 >  Typecho开启伪静态并隐藏index.php

Typecho后台设置永久链接后,会在域名后加上index.php,很多人都接受不了。例如如下网址:

http://www.landui.com/index.php/archives/37/

但我们希望最终的形式是这样:

http://www.landui.com/archives/37.html


  1. 后台配置typecho伪静态
    typecho后台,开启伪静态,并选择你喜好的url形式:


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

nginx配置

server {
        listen          80;
        server_name     landui.com;
        root            /home/landui/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/landui.log combined;
    }

如果还有问题,请参考:http://www.landui.com/servers?s%5B%5D=nginx

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>

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


提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: