Typecho开启伪静态并隐藏index.php
Typecho后台设置永久链接后,会在域名中带如index.php,有的“强迫症患者”表示根本接受不了。
例如如下网址:https://www.zhujidaba.com/index.php/archives/37/
但我们希望这样显示:https://www.zhujidaba.com/archives/37.html
那么我们如何做到这样的效果?
1.后台开启并配置typecho伪静态
后台“永久链接设置”开启伪静态,并选择url形式:
2.配置服务器的rewrite规则
如果在保存上述配置的时候,typecho无法自动配置,则需要手动配置服务器的rewrite规则。
nginx配置
server {
listen 80;
server_name yourdomain.com;
root /home/wwwroot/your_directory;
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;
}
相关参考:http://docs.typecho.org/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>
可以放在apache的conf文件,或者放在.htaccess中。
文章参考:Typecho开发者中文网 - Typecho开启伪静态并隐藏index.php
猜您喜欢