Typecho后台设置永久链接后,会在域名后加上index.php,很多人都接受不了。例如如下网址:http://qqdie.com/index.php/archives/37/,但我们希望最终的形式是这样:http://qqdie.com/archives/37.html。那么我们如何做到这样的效果?
1.配置服务器的rewrite规则
如果在保存上述配置的时候,typecho无法自动配置,那么你可能需要手动配置服务器的rewrite规则。
Linux Apache 环境 (.htaccess):
<IfModule mod_rewrite.c>
RewriteEngine On
# 下面是在根目录,文件夹要修改路径
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
Linux Apache 环境(Nginx):
location / {
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;
}
}
Windows IIS 伪静态 (httpd.ini):
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# 中文tag解决
RewriteRule /tag/(.*) /index\.php\?tag=$1
# sitemapxml
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# 内容页
RewriteRule /(.*).html /index.php/$1.html [L]
# 评论
RewriteRule /(.*)/comment /index.php/$1/comment [L]
# 分类页
RewriteRule /category/(.*) /index.php/category/$1 [L]
# 分页
RewriteRule /page/(.*) /index.php/page/$1 [L]
# 搜索页
RewriteRule /search/(.*) /index.php/search/$1 [L]
# feed
RewriteRule /feed/(.*) /index.php/feed/$1 [L]
# 日期归档
RewriteRule /2(.*) /index.php/2$1 [L]
# 上传图片等
RewriteRule /action(.*) /index.php/action$1 [L]
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>
2.后台配置typecho伪静态
在typecho后台,开启伪静态,并选择你喜好的url形式即可。
本文来源:https://qqdie.com/archives/typecho-open-pseudo-static-get-rid-of-that-pesky-index-the-php.html
博主真是太厉害了!!!
叼茂SEO.bfbikes.com
不错不错,我喜欢看 https://www.jiwenlaw.com/
看的我热血沸腾啊https://www.237fa.com/
不错不错,我喜欢看 https://www.ea55.com/
想想你的文章写的特别好www.jiwenlaw.com
文章的确不错啊https://www.cscnn.com/
真棒!
你的文章让我感受到了无尽的欢乐,谢谢分享。 http://www.55baobei.com/upT9ZCvtoF.html
真棒!
《望夫成龙1990国语》喜剧片高清在线免费观看:https://www.jgz518.com/xingkong/36034.html