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} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ /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 hourCacheClockRate 3600RepeatLimit 32# 中文tag处理RewriteRule /tag/(.*) /index\.php\?tag=$1# sitemapxmlRewriteRule /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]# feedRewriteRule /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情势:
具体操作,依据本人实际操作以下
我的虚拟主机是apache的,在网站根目录找到.htaccess,有的没有多是设置了隐蔽文件,显现隐蔽文件就可以看到了。
然后编辑.htaccess文件,到场上文中对应的apache设置代码保留。然后去typecho程序背景,设置>永远链接,根据上文中图片的设置,保留即可。

评论列表