TypechoJoeTheme

至尊技术网

统计
登录
用户名
密码
/
注册
用户名
邮箱

Typecho开启伪静态实现隐藏入口文件index.php

2019-06-24
/
0 评论
/
969 阅读
/
正在检测是否收录...
06/24


Typecho后台设置永久链接后,会在域名后加上index.php,看着心里不舒服,可以里利用开启伪静态让它不显示index.php入口文件。
例如

https://www.zzwws.cn/index.php/archives/23/

开启伪静态后

https://www.zzwws.cn/archives/23/

发现index.php不见了,当然后台设置永久链接也可以改成自己喜欢的。
下面是几种WebServer的伪静态规则
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>

NGINX

if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php$1 last;
}

IIS

[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]
当然后台开启伪静态后typecho无法自动配置,然后需要手动配置服务器的rewrite规则,或者在后台里启用地址重写功能。
Typecho
朗读
赞(0)
版权属于:

至尊技术网

本文链接:

https://www.zzwws.cn/archives/24/(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. 五千多
    2025-05-03
  2. 强强强
    2025-04-07
  3. jesse
    2025-01-16
  4. sowxkkxwwk
    2024-11-20
  5. zpzscldkea
    2024-11-20

标签云