还不快抢沙发

添加新评论

Typecho后台设置永久链接后,会在域名后加上index.php,很多人都接受不了。例如如下网址:`http://www.typechodev.com/index.php/archives/37/`,但我们希望最终的形式是这样:`http://www.typechodev.com/archives/37.html`。那么我们如何做到这样的效果? ### 后台配置typecho伪静态 如图,在[typecho](http://typecho.org/ "typecho")后台,开启伪静态,并选择你喜好的url形式: ![](http://image.rdhonor.com/2017/10/12/jl8xo768fent3idglpozzy4q.png) ### 配置服务器的rewrite规则 ```ngix 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配置 ```apache RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] ``` > 此配置可以放在apache的conf文件中,或者放在.htaccess中。