溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

typecho如何去掉index.php

發(fā)布時間:2020-10-09 16:59:22 來源:億速云 閱讀:248 作者:小新 欄目:編程語言

這篇文章將為大家詳細(xì)講解有關(guān)typecho如何去掉index.php,小編覺得挺實(shí)用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

typecho去掉index.php的方法:首先配置服務(wù)器的rewrite規(guī)則;然后修改nginx以及apache配置;最后在后臺配置typecho偽靜態(tài)即可。

typecho開啟偽靜態(tài),去掉那個討厭的index.php

Typecho后臺設(shè)置永久鏈接后,會在域名后加上index.php,很多人都接受不了。例如如下網(wǎng)址:http://qqdie.com/index.php/archives/37/,但我們希望最終的形式是這樣:http://qqdie.com/archives/37.html。那么我們?nèi)绾巫龅竭@樣的效果?

1.配置服務(wù)器的rewrite規(guī)則

如果在保存上述配置的時候,typecho無法自動配置,那么你可能需要手動配置服務(wù)器的rewrite規(guī)則。

Linux Apache 環(huán)境 (.htaccess):

<IfModule mod_rewrite.c>
RewriteEngine On
# 下面是在根目錄,文件夾要修改路徑
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
Linux Apache 環(huán)境(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 偽靜態(tài) (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]
# 內(nèi)容頁
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偽靜態(tài)

如圖,在typecho后臺,開啟偽靜態(tài),并選擇你喜好的url形式:

typecho如何去掉index.php

具體操作,根據(jù)本人實(shí)際操作如下

我的虛擬主機(jī)是apache的,在網(wǎng)站根目錄找到.htaccess,有的沒有可能是設(shè)置了隱藏文件,顯示隱藏文件就能看到了。

然后編輯.htaccess文件,加入上文中對應(yīng)的apache配置代碼保存。然后去typecho程序后臺,設(shè)置>永久鏈接,按照上文中圖片的設(shè)置,保存即可。

關(guān)于typecho如何去掉index.php就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI