php伪静态不支持中文,wordpress伪静态如何支持中文(目前不支持分类目录中文)...
自定義結構可以用你自己喜歡的,比如可以只用用“/%post_id%.html”,這樣的訪問地址就會是“http://xxx.com/id.html”;當然你也可以用“/%post_id%”,這樣的訪問地址就會是“http://xxx.com/id/”等等,后綴名“html”也可隨便修改,官方提供了如下一些參數。
%year% 年份
%monthnum% 月份
%day% 日期
%hour% 小時
%minute% 分鐘
%second% 秒
%postname% 文章名
%post_id% 文章的ID
%category% 目錄
%author% 作者
修改好你需要的偽靜態后,就要保存更改。然后要為博客的根目錄添加一個“httpd.ini”文件,文件創建方法為新建一記事本,另存為httpd.ini,代碼如下。
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# wordpress 偽靜態規則
# For tag(中文標簽以及標簽翻頁的規則)
RewriteRule /tag/(.*)/page/(\d+)$ /index\.php\?tag=$1&paged=$2
RewriteRule /tag/(.+)$ /index\.php\?tag=$1
# For category(中文分類以及分類翻頁的規則)
RewriteRule /category/(.*)/page/(\d+)$ /index\.php\?category_name=$1&paged=$2
RewriteRule /category/(.*) /index\.php\?category_name=$1
# For sitemapxml
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]
這樣就可以支持偽靜態了,但是還不支持中午,需要支持中文還需要修改一個文件,“wp-include”目錄下的“class-wp.php”文件。
親測5.4版本這樣修改,其他版本也可以類似這樣修改!
第一步:找到
$pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : '';
修改為:
$pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], "UTF-8", "GBK");'';
第二步:找到
list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
修改為:
list( $req_uri ) = mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK");
就這樣,自己可以支持中文的偽靜態狀況了,TAG標簽頁等都可以打開了的。
目前仍然有缺陷,就是文章的分類目錄是支持中文的,但是在點擊下一頁之后,它會爆出找不到頁面的錯誤,連接中本應是分類名稱的中文變成了亂碼。在規則上沒找到合適的辦法,所以就先將分類目錄的別名改為了英文的名字,注意是別名不是本身的名字。
總結
以上是生活随笔為你收集整理的php伪静态不支持中文,wordpress伪静态如何支持中文(目前不支持分类目录中文)...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CMU本科计算机科学,CMU计算机科学学
- 下一篇: python drop_duplicat