|
plog 漢化使用手記
[ 2005-09-22 14:58 | 作者: coolsky ]
作為多用戶blog系統(tǒng),plog具有強大的影響力,最近我也拿plog用了一下
順便記錄一下使用過程中要注意的問題 1.漢化 目前版本是1.0.1 Plog程序結構非常好,不過也難以看懂和進行修改。 plog發(fā)行版本已經(jīng)申明不會出GB2312的版本,只有UTF-8 這個問題也困擾了我很久,老外怎么就喜歡用連中國人都不懂的編碼呢 不過要與國際接軌 還真得用utf-8 我不喜歡utf-8 所以我把它漢化為GB2312了 其實plog的漢化非常簡單 記事本就有這個功能 ./locale/locale_zh_CN.php是中文語言包 使用utf-8編碼 把它打開 復制所有內(nèi)容到記事本中 然后另存為文件覆蓋locale_zh_CN.php 這時文件大小將由54K 減小到47K 這個文件就是Gb2312的語言包了 別慌 還有一個地方?jīng)]改 打開這個文件 找到$messages[‘encoding‘]一行 將"utf-8" 替換為gb2312就可以了 漢化完畢 2.配置二級域名 使用者都希望能讓申請blog的用戶擁有xx.xx.cn這樣的二級域名以代替原來又臭又長的一大串參數(shù) 1)首先要配置您自己的域名使它支持泛域名解析 所謂泛域名解析是DNS域名提供商提供的一種服務, 您可以使用*. 都能解析到您所在的服務器IP地址 你可以通過自己配置DNS服務器或者向供應商要求這種服務 一般是需要另外加費用的 2)登陸到plog后臺控制中心->常規(guī)設置->subdomains_enabled 這個選項 將他啟用 同時設置好您base_url地址和subdomains_base_url 以我為例: base_url http://www./blog subdomains_base_url http://{username}. 這里的username是plog內(nèi)的一種變量 設置為username 就可以采用用戶名為二級域名 如果你設置為{blogid} 那么二級域名就是blogid的值 3)設置url 在URL設置里面選擇"自定義鏈接" 我不采用plog自帶的mod rewrite方式 我自己定義基本格式 我設置為 request_format_mode : /archive/{year}/{month}/{day}/{blogid}/{postid}.html$ category_link_format: /categories/{blogid}/{catid}$ archive_link_format : /archive/{blogid}/{year}{month}{day} user_posts_link_format :/{blogname}/user/{username}$ post_trackbacks_link_format :/{blogname}/post/trackbacks/{postname}$ 其他的我還沒來得及改 就拿這么多說明吧 以上格式顧名思義了 下面還要在apache的httpd.conf中配置mod rewrite 我不推薦plog自帶的.htaccess方式 那樣對服務器負擔比較大 不過虛擬主機支持的話 也只能用.htaccess方式 我以虛擬主機來說明 <VirtualHost 61.152.114.86> DocumentRoot /usr/etc/wwwroot/www./blog ServerAdmin coolsky@ ServerName *. ServerSignature email DirectoryIndex summary.php index.php index.html index.htm default.php RewriteEngine On #RewriteMap blog txt:/usr/etc/wwwroot/www./blog/blog_url.txt #RewriteCond %{REQUEST_URI} ^/$ #RewriteCond %{HTTP_HOST} ^([^.]+).$ [NC] #RewriteCond ${blog:%1} ^(.*)$ [NC] #RewriteRule ^/(.*)$ %1/$1 RewriteRule ^/archive/[^.]+/[^.]+/[^.]+/([0-9]+)/([0-9]+)+\.html$ /index.php?op=ViewArticle&blogId=$1&articleId=$2 [L,NC] # Category view (i.e. /plog/88_userfoo/categories/4_cat-foobar.html) RewriteRule ^/categories/([0-9]+)/([0-9]+)$ /index.php?op=Default&blogId=$1&postCategoryId=$2 [L,NC] RewriteRule ^/test.html$ /test.php[L,NC] # Monthly archive (i.e. /plog/1_userfoo/archive/200401.html) #RewriteRule ^/([0-9]+)_[^/]+/archive/([0-9]{6})\.html$ /index.php?blogId=$1&Date=$2 [L,NC] # Daily and Month archive (i.e. /plog/1_blogfoo/archive/20040101.html) RewriteRule ^/archive/([0-9]+)/([0-9]+)$ /index.php?blogId=$1&Date=$2 [L,NC] #文章歸檔 RewriteRule ^/([0-9]+)/$ /index.php?op=Template&blogId=$1&show=archives [L,NC] # Album (i.e. /plog/88_userfoo/albums/34_title-foo-bar.html) RewriteRule ^/([0-9]+)_[^/]+/albums/([0-9]+)_[^.]+\.html$ /index.php?op=ViewAlbum&blogId=$1&albumId=$2 [L,NC] # Albums (i.e. /plog/88_userfoo/albums/) RewriteRule ^/([0-9]+)_[^/]+/albums/$ /index.php?op=ViewAlbum&blogId=$1&albumId=0 [L,NC] # Category-Feeds (i.e. /plog/3_userfoo/feeds/categories/2_category/atom) RewriteRule ^/([0-9]+)_[^/]+/feeds/categories/([0-9]+)_[^.]+/(.*)$ /rss.php?blogId=$1&categoryId=$2&profile=$3 [L,NC] # Feeds (i.e. /plog/3_userfoo/feeds/atom) RewriteRule ^/([0-9]+)_[^/]+/feeds/(.*)$ /rss.php?blogId=$1&profile=$2 [L,NC] # Trackbacks (i.e. /plog/3_userfoo/trackbacks/34_title-foo-bar.html) RewriteRule ^/([0-9]+)_[^/]+/trackbacks/([0-9]+)_[^.]+\.html$ /index.php?op=Trackbacks&blogId=$1&articleId=$2 [L,NC] # Comment form (i.e. /plog/88_userfoo/comment/34_title-foo-bar.html) RewriteRule ^/([0-9]+)_[^/]+/comment/([0-9]+)_[^.]+\.html$ /index.php?op=Comment&blogId=$1&articleId=$2 [L,NC] # Resources (i.e. /plog/88_userfoo/resources/this-is-a-resource-name.pdf.html) RewriteRule ^/([0-9]+)_[^/]+/resources/([^.]+)\.([^.]+)\.html$ /index.php?op=ViewResource&blogId=$1&resource=$2.$3 [L,NC] # Download a resource (i.e. /plog/88_userfoo/get/this-is-a-resource-name.pdf) RewriteRule ^/([0-9]+)_[^/]+/get/(.+)$ /resserver.php?blogId=$1&resource=$2 [L,NC] # Static Pages (i.e /plog/3_userfoo/demosites) RewriteRule ^/([0-9]+)_[^/]+/(.+)$ /index.php?op=Template&blogId=$1&show=$2 [NC] # A non-default blog (i.e. /plog/88_userfoo) RewriteRule ^/([0-9]+)_[^/]+$ /index.php?blogId=$1 [L,NC] # Daly archive (i.e. /plog/1_userfoo/archive/20040101.html) RewriteRule ^/([0-9]+)_[^/]+/archive/([0-9]{8})\.html$ /index.php?blogId=$1&Date=$2 [L,NC] </VirtualHost> 上面代碼下面部分采用了plog的.htaccess文件中默認的,我只改了和修改url對應的部分 以上配置好以后 我們只需要重啟apache 你就會發(fā)現(xiàn) 如果你申請了名字為coolsky的用戶 你就可以用coolsky.這個域名進行訪問了 如果你發(fā)的文章id是1 那么你文章的鏈接就會是"http://coolsky./archive/2005/09/14/18/1.html" 的格式 其他類似 這樣還不行 如果你輸入www.他也會自動轉到這個地址上 不是我們的初衷 要保留www.,blog.的域名 我們還需要在apache配置一個虛擬主機 在上面的配置文件下面加上 <VirtualHost 61.152.114.86> DocumentRoot /usr/etc/wwwroot/www./ ServerAdmin coolsky@ ServerName www. ServerSignature email DirectoryIndex summary.php index.html index.htm default.php </VirtualHost> 這樣我們可以用http://www./blog/summary.php來訪問首頁 如何才能把summary.php設置為首頁呢,也就是說 但是當我輸入http://blog.的時候是轉向是index.php 而不是summary.php 雖然在上面的第一個虛擬主機配置中我們定義了DirectoryIndex summary.php 但是實際卻沒有起作用 解決方法: 其實我沒找到很好的方法 我在index.php中加入以下代碼進行轉向: if($_SERVER[‘HTTP_HOST‘]=="blog."){ header(‘location: http://www./blog/‘); } 4.其他備注 系統(tǒng)默認是要發(fā)郵件 確認后才開通的 修改成既時開通方法: 郵件設置->check_email_address_validity 和email_service_enabled 都改為否 另外如果要整合數(shù)據(jù)庫 可以通過外部提交到注冊頁面的第二步或第三步 并用post模擬原始提交post數(shù)據(jù). [本日志最后由coolsky于2006-02-14 16:35編輯]
引用通告地址:
GB2312 http:///trackback.php?id=133&encode=gb2312 UTF-8 http:///trackback.php?id=133&encode=utf-8 Big5 http:///trackback.php?id=133&encode=big5 [2005-11-04 06:44:41 AM ]
寫的真不錯。謝謝!
你好,網(wǎng)上好像只有你這里講得最詳細,想請教。
我是合租的服務器,也只能用.htaccess方式吧,用的是APACHE1.3.33,裝Plog 1.0.2 beta,.htaccess的前面好像和你的不同,是這樣: <Files .htaccess> deny from all </Files> <Files config.properties.php> deny from all </Files> Options -Indexes Options +FollowSymLinks <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /plog/ # Permalink to the blog entry (i.e. /plog/1_userfoo/archive/3_title-foo-bar.html) RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]+)_[^.]+\.html$ index.php?op=ViewArticle&blogId=$1&articleId=$2 [L,NC] # Monthly archive (i.e. /plog/1_userfoo/archive/200401.html) RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{6})\.html$ index.php?blogId=$1&Date=$2 [L,NC] 。。。 我該怎么修改呢?多謝指點??! 續(xù)前:忘了說清楚我的目的是配置PLOG二級域名,你這里的1、2步我已完成,第3步URL設置也有點不清楚,可以只把第一項request_format_mode改為Apache Modrewrite,而其他不動嗎?其他項的值都類似/blog/{blogname}/{catname}/{year}/{month}/{day}/{postname}$,而我是把Plog系統(tǒng)裝在plog目錄里,這里的/blog/都應改成/plog/么?
改.htaccess應該是第四步吧? 謝謝??! 管理員回復于 2006-11-16 01:58:33 AM
如果只把第一項request_format_mode改為Apache Modrewrite 那么格式是plog內(nèi)定的
最好改用:自定義鏈接 然后可以自定義那個類似/blog/{blogname}/{catname}/{year}/{month}/{day}/{postname}$目錄 對于你的目錄確實應該把blog改為plog 修改.htaccess對應的是http.conf修改的那一步 基本上是一致的 |
|
|
來自: Ralf_Jones > 《PHP》