不同环境下Typecho的伪静态设置

Typecho是一个基于PHP的简洁的开源博客程序。它使用多种数据库储存数据,在GNU GPLv2许可证下发行。相对于WordPress而言,更加 简洁,原生支持Markdown,非常易于写文章。
对于Typecho开启伪静态一般需要两步,第一步现在Typecho后台进行设置。然而Typecho后台设置永久链接后,会在域名后加上index.php,这一点可以通过利用服务器的rewrite来隐藏。

Linux Nginx环境

Nginx通过修改nginx.conf来实现功能控制,只需要在server模块里添加以下代码即可:

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

Linux Apache环境

可以通过在apache的conf配置文件中添加代码实现,也可以通过在网站根目录下的.htaccess中添加代码实现:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

</IfModule>

Windows IIS环境

windows下一般是通过修改根目录下的httpd.ini文件或者web.config文件实现。
修改httpd.ini文件

[ISAPI_Rewrite]
RewriteRule /(.*).html /index.php/$1.html [L]

也可以设置的更详细些:

[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]

修改web.config

    <?xml version="1.0" encoding="UTF-8"?>
    <!--web.config url rewrite-->
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="typecho" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php/{R:1}"/>
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>

至于究竟是用httpd.ini,还是web.config,一般优先尝试web.config,或者看看目录下已经有的是哪一个。。
搬砖自https://www.quanyin.me/2018/09/typecho-rewrite/

34 条评论

Stevtafe Stevtafe

Cialis Informacion En Espanol Achat Baclofene En Ligne Amoxicillin For Infants viagra online prescription Cialis Alle Erbe Funziona Acheter Viagra Avec Paypal Comprar Cialis 5 Mg Generico

回复
FranRip FranRip

Comprare Cialis In Italia Amoxicillin Clavulanate Aka Augmentin 250m Compra Cialis Barcelona cheapest cialis Left Amoxicillin Out Over Night

回复
Stevtafe Stevtafe

discount isotretinoin acne for sale best website visa Cialis India Online levitra canada Cheap Safe Viagra Best Prices For Legal Levitra

回复
Stevtafe Stevtafe

Amoxicillin And Clavulanate Oral Suspension Buy Tadacip Uk Generic Bentyl Drugs By Money Order cialis canada Ou Acheter Viagra En Ligne Buy Cialis Online Without Prescription

回复
FranRip FranRip

Parafarmacia Online Propecia Viagra On Line Purchases Levitra Overdose cheapest cialis Purchasing Finasteride Levitra Ohne Rezept Verkaufen Come Assumere Levitra

回复
Lesinhaws Lesinhaws

Healthy Man Cheapest Non Prescription Celias generic cialis overnight delivery Stendra Mastercard Accepted Tyneside Buy Buspar Cheap Cialis Rue Du Four

回复
Stevtafe Stevtafe

Cialis 20mg For Sale Over The Counter Fertility Drugs canadian levitra Numeros Con Propecia Cheap Misoprostol Sildenafil Citrate Sales In Canada

回复
FranRip FranRip

Levitra Costo Confezione By Prednisone W Not Prescription zoloft Rash On Amoxicillin Get Cialis Without Prescription

回复
Lesinhaws Lesinhaws

Kamagra Deutschland Levitra Amoxicillin Capsules For Bladder Infection viagra prescription Ficha Tecnica De Propecia Cialis Potenzmittel Rezeptfrei Im Internet Bestellen

回复
Oneple Oneple

Order cheap cialis buy cheap cialis online buy cialis pill buy generic cialis online buying cialis in canada fast shipping cialis Buy Cialis Online which viagra is best buy cheap viagra online

回复
jedhiels jedhiels

Generic cialis from india buy cialis online does generic work cialis pills buy cheap cialis online 1 a day cialis 20mg buy generic cialis online woman cialis pills buy cheap cialis online viagra timeline buy generic viagra online

回复
PoobHobe PoobHobe

1 a day cialis 20mg buy cialis online viagra flomax interaction cialis generic buy cheap cialis online indian buy generic cialis buy generic cialis online brand cialis online buy cheap cialis online viagra for men free samples buy generic viagra online

回复
Treata Treata

Buy cialis generic pharmac buy cheap cialis online us cialis generic vaistas buy generic cialis online cheap cialis pills Buy Cialis Online viagra at age 90 buy cheap viagra online

回复
annouch annouch

Cialis 40 mg tablets cialis cheap generic cialis generic cialis any good generic cialis online tadalafil research chemicals cialis pills order Buy Cheap Cialis Online viagra and taliban cialis pills generic cialis online best place to buy cialis cialis medco cialis online pharmacy viagra

回复
fiffunc fiffunc

Web md cialis pills order buy cheap cialis generic cialis buy online cialis online cialis indian viagra for women cialis generic cialis cheap is generic cialis good Buy Cheap Cialis Online buy cialis 5mg generic cialis generic cialis prices

回复
owerve owerve

Cialis pills online generic buy cialis generic buy cialis line online cialis buy generic cialis cheap cialis viagra beograd cialis pills buy cialis online cheap cialis online buy Buy Cheap Cialis Online viagra pills canada buy cialis online

回复
idionse idionse

Cialis 20 mg tablets cialis sex cialis pills cialis canada cialis generic maintain an erection buy cialis online cheap buy cialis online online cialis price of daily cialis 20mg online cialis cialis 20mg rezeptfrei

回复
Stolima Stolima

Cialis pills online cialis generic buy tadalafil india no prescription buy Buy Generic Cialis Online sertraline viagra cialis pills cheap generic cialis buy cialis europe buy cheap cialis generic cialis tadalafil 20mg cialis buy cialis generic find cialis generic buy cialis online cheap generic cialis usa

回复
hedeales hedeales

Buy cialis online now buy cialis generic cialis generico online generic cialis acheter cialis 20mg buy generic cialis online montreal cialis generic buy buy cialis online cheap cheap cialis soft tabs cialis generic buy generic cialis us

回复
duaskils duaskils

Generic sale cialis pills cialis online brand cialis name online order cialis coupon cialis cheap cialis generic cialis online prescription buy cheap cialis coupon order generic cialis online cialis coupon cheapest generic cialis online cheap cialis cialis pills online buy

回复
foupeFox foupeFox

Cheap online female cialis cialis cheap overdose on cialis generic cialis brand name cialis online Buy Cheap Cialis Online generic cialis lowest price cialis online generic cialis mexico cheap cialis generic cialis work

回复
Insirm Insirm

Generic cialis cialis cialis buy cialis online canada cialis generic runny nose cheap cialis viagra cialis generic kamagra cialis generic cialis without prescription cialis online cialis for sale online buy cialis online cialis mail order cialis buy tadalafil online cialis

回复
faitles faitles

Buy cialis online usa buy generic cialis name cialis tablets buy generic cialis online order generic cialis online buy cialis online cheap india generic cialis cialis coupon cialis tablets vega online cialis find cialis generic

回复
oxilky oxilky

Medicamentul reductil cialis 20mg buy cheap cialis coupon cialis discount online cialis cheap viagra shipped overnight cialis generic cialis coupon taking without ed cialis pills cialis buy generic cialis online reductil in romania cialis 20mg buy cialis online cheap cheap cialis si cialis coupon legitimate cialis generic

回复
sweague sweague

Buy real cialis online buy generic cialis pics of cialis pills cheap generic cialis prednisone and hyperglycemia cialis generic pills generic cialis order cialis cialis coupon diabetes cialis tablets cheap generic cialis renova expres cialis pills cheap generic cialis non generic cialis cialis

回复
unewalt unewalt

Viagra pills paypal cialis generic cialis cheap generic cialis online cheap cialis cialis pills discount generic cialis price of cialis pills Buy Cheap Cialis Online alcohol cialis generic Buy Cheap Cialis Online pills buy tadalafil Buy Cialis Online viagra trial voucher buy cialis online

回复

发表评论

电子邮件地址不会被公开。 必填项已用*标注