Discuz!X Nginx 的偽靜態(Rewrite)規則

Discuz!X是康盛創想(Comsenz)推出的一個以社區為基礎的專業建站平臺,讓論壇(BBS)、個人空間(SNS)、門戶(Portal)、群組(Group)、應用開放平臺(Open Platform)充分融合于一體,幫助網站實現一站式服務。

江陰論壇就是建立在Discuz!X的一個江陰本地論壇。

把下面代碼存為discuzx.conf,然后在域名配置文件(jyrj.net.conf)中嵌入(include discuzx.conf)就行了。

1
2
3
4
5
6
7
8
9
10
11
12
13
location / {
    rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
    rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
    rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
    rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
    rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
    rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
    rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
    rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
    if (!-e $request_filename) {
        return 404;
    }
}

ECShop Nginx 的偽靜態(Rewrite)規則

ECShop是一款開源免費的網上商店系統。由專業的開發團隊升級維護,為您提供及時高效的技術支持,您還可以根據自己的商務特征對ECShop進行定制,增加自己商城的特色功能。

把下面代碼存為ecshop.conf,然后在域名配置文件(romangift.com.conf)中嵌入(include ecshop.conf)就行了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
location / {
    if (!-e $request_filename) {
        rewrite "^/index\.html" /index.php last;
        rewrite "^/category$" /index.php last;
        rewrite "^/feed-c([0-9]+)\.xml$" /feed.php?cat=$1 last;
        rewrite "^/feed-b([0-9]+)\.xml$" /feed.php?brand=$1 last;
        rewrite "^/feed\.xml$" /feed.php last;
        rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last;
        rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last;
        rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last;
        rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3 last;
        rewrite "^/category-([0-9]+)-b([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2 last;
        rewrite "^/category-([0-9]+)(.*)\.html$" /category.php?id=$1 last;
        rewrite "^/goods-([0-9]+)(.*)\.html" /goods.php?id=$1 last;
        rewrite "^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last;
        rewrite "^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$" /article_cat.php?id=$1&page=$2 last;
        rewrite "^/article_cat-([0-9]+)(.*)\.html$" /article_cat.php?id=$1 last;
        rewrite "^/article-([0-9]+)(.*)\.html$" /article.php?id=$1 last;
        rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html" /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last;
        rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2&page=$3 last;
        rewrite "^/brand-([0-9]+)-c([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2 last;
        rewrite "^/brand-([0-9]+)(.*)\.html" /brand.php?id=$1 last;
        rewrite "^/tag-(.*)\.html" /search.php?keywords=$1 last;
        rewrite "^/snatch-([0-9]+)\.html$" /snatch.php?id=$1 last;
        rewrite "^/group_buy-([0-9]+)\.html$" /group_buy.php?act=view&id=$1 last;
        rewrite "^/auction-([0-9]+)\.html$" /auction.php?act=view&id=$1 last;
        rewrite "^/exchange-id([0-9]+)(.*)\.html$" /exchange.php?id=$1&act=view last;
        rewrite "^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last;
        rewrite "^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last;
        rewrite "^/exchange-([0-9]+)-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2 last;
        rewrite "^/exchange-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1 last;
    }

    if (!-e $request_filename) {
        return 404;
    }
}

記事狗 Nginx 的偽靜態(Rewrite)規則

記事狗微博系統是一套業界領先的開源PHP微博程序,其支持Web、手機、短信、QQ機器人等多種方式發布內容,并可通過QQ即時通知、站外調用、同步到新浪微博、騰訊微博(可使用微博賬戶登錄、注冊綁定)等傳播內容,是現在最熱門、最火爆的互動系統。記事狗微博集成了Ucenter模塊,可與所有集成該模塊的系統(比如Discuz、Ecshop等)進行無縫整合,完美實現用戶同步注冊、登陸、退出,同步上傳頭像,同步修改密碼,讓網站已有用戶輕松使用。

把下面代碼存為jsg.conf,然后在域名配置文件(t.jyrj.net.conf)中嵌入(include jsg.conf)就行了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
location / {
    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;
    }

    if (!-e $request_filename) {
        return 404;
    }
}

常用的css命名規則

注釋的寫法:
/* Footer */
內容區
/* End Footer */

id的命名:

(1)頁面結構

容器: container

頁頭:header

內容:content/container

頁面主體:main

頁尾:footer

導航:nav

側欄:sidebar

欄目:column

頁面外圍控制整體布局寬度:wrapper

左右中:left right center
繼續閱讀

WordPress XML-RPC Ping Services

http://1470.net/api/ping
http://api.feedster.com/ping
http://api.moreover.com/ping
http://api.moreover.com/RPC2
http://api.my.yahoo.com/RPC2
http://api.my.yahoo.com/rss/ping
http://bblog.com/ping.php
http://bitacoras.net/ping
http://blo.gs/ping.php
http://blog.goo.ne.jp/XMLRPC
http://blog.iask.com/RPC2
http://blog.youdao.com/ping/RPC2
http://blogdb.jp/xmlrpc
繼續閱讀

DEDECMS子欄目頁面和內容頁調用頂級欄目

新建一個文件 “/include/taglib/type2.lib.php”,代碼如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php   if(!defined('DEDEINC')) exit('Request Error!');
function lib_type2(&$ctag,&$refObj)
{
    global $dsql,$envs;

    $attlist='typeid|0';
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $innertext = trim($ctag->GetInnerText());

    if($typeid==0) {
        $typeid = ( isset($refObj->TypeLink->TypeInfos['id']) ? $refObj->TypeLink->TypeInfos['id'] : $envs['typeid'] );
    }

  if(empty($typeid)) return '';

    $row = $dsql->GetOne("SELECT id,topid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
                          FROM `#@__arctype` WHERE id='$typeid' "
);
    if(!is_array($row)) return '';
    if($row['topid']==0){$row['topid']=$row['id'];} //文章頁獲取頂級欄目ID(topid)
    if(trim($innertext)=='') $innertext = GetSysTemplets("part_type_list.htm");
   
    $dtp = new DedeTagParse();
    $dtp->SetNameSpace('field','[',']');
    $dtp->LoadSource($innertext);
    if(!is_array($dtp->CTags))
    {
        unset($dtp);
        return '';
    }
    else
    {
        $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
        foreach($dtp->CTags as $tagid=>$ctag)
        {
            if(isset($row[$ctag->GetName()])) $dtp->Assign($tagid,$row[$ctag->GetName()]);
        }
        $revalue = $dtp->GetResult();
        unset($dtp);
        return $revalue;
    }
}

調用方法:

1
2
3
{dede:type2}
<a href="[field:typelink /]">[field:typename /]</a>
{/dede:type2}

WordPress文章ID不連續的解決方法

WordPress 3.1.2文章ID不連續的解決方法:
1.打開wp-config.php文件,在define (‘WPLANG’, ‘zh_CN’);下一行添加代碼

1
2
define('WP_POST_REVISIONS', false);
define('AUTOSAVE_INTERVAL', false);

2.打開wp-admin\post-new.php(第46行)和wp-admin\post.php(第177行)兩個文件,將下面的這段代碼分別注釋或刪除。

1
wp_enqueue_script('autosave');

3.打開wp-admin\includes\post.php文件,找到代碼

1
if ( $create_in_db ) {

在它的前一行添加

1
$create_in_db = false;

DEDECMS留言板模塊引用頂級欄目導航

第一步:打開”/include/extend.func.php”
然后在該文件中加入一個函數,代碼如下:

1
2
3
4
5
6
7
8
function pasterTempletDiy($path) {
    require_once(DEDEINC."/arc.partview.class.php");
    global $cfg_basedir,$cfg_templets_dir;
    $tmpfile = $cfg_basedir.$cfg_templets_dir."/".$path;//模版文件的路徑
    $dtp = new PartView();
    $dtp->SetTemplet($tmpfile);
    $dtp->Display();
}

第二步,打開留言本的模版文件,默認的是/templets/plus/guestbook.htm
在該文件的”“下面,加入如下代碼:

1
2
3
<?php
    pasterTempletDiy("default/head.htm");
?>

Discuz調用jQuery沖突的解決辦法

將jquery.js在common.js之后載入,在調用jQuery的函數前使用一下代碼:

1
jQuery.noConflict();

之后便可以使用jQuery()來代替jQuery原來的$()函數,而$()函數則是原來Discuz的$()函數。

例:

1
2
3
4
5
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery("div p").hide();
</script>

Crontab實例

cron是一個linux下的定時執行工具,可以在無需人工干預的情況下運行作業。由于Cron 是Linux的內置服務,但它不自動起來,可以用以下的方法啟動、關閉這個服務:

/sbin/service crond start //啟動服務
/sbin/service crond stop //關閉服務
/sbin/service crond restart //重啟服務
/sbin/service crond reload //重新載入配置

你也可以將這個服務在系統啟動的時候自動啟動:
在/etc/rc.d/rc.local這個腳本的末尾加上:
/sbin/service crond start

現在Cron這個服務已經在進程里面了,我們就可以用這個服務了,Cron服務提供以下幾種接口供大家使用:

1、直接用crontab命令編輯

cron服務提供crontab命令來設定cron服務的,以下是這個命令的一些參數與說明:

crontab -u //設定某個用戶的cron服務,一般root用戶在執行這個命令的時候需要此參數
crontab -l //列出某個用戶cron服務的詳細內容
crontab -r //刪除某個用戶的cron服務
crontab -e //編輯某個用戶的cron服務

比如說root查看自己的cron設置:crontab -u root -l
再例如,root想刪除fred的cron設置:crontab -u fred -r
在編輯cron服務時,編輯的內容有一些格式和約定,輸入:crontab -u root -e
進入vi編輯模式,編輯的內容一定要符合下面的格式:*/1 * * * * ls >> /tmp/ls.txt

這個格式的前一部分是對時間的設定,后面一部分是要執行的命令,如果要執行的命令太多,可以把這些命令寫到一個腳本里面,然后在這里直接調用這個腳本就可以了,調用的時候記得寫出命令的完整路徑。時間的設定我們有一定的約定,前面五個*號代表五個數字,數字的取值范圍和含義如下:

分鐘 (0-59)
小時 (0-23)
日期 (1-31)
月份 (1-12)
星期 (0-6)//0代表星期天

除了數字還有幾個個特殊的符號就是”*”、”/”和”-“、”,”,*代表所有的取值范圍內的數字,”/”代表每的意思,”*/5″表示每5個單位,”-“代表從某個數字到某個數字,”,”分開幾個離散的數字。以下舉幾個例子說明問題:

每天早上6點

0 6 * * * echo “Good morning.” >> /tmp/test.txt //注意單純echo,從屏幕上看不到任何輸出,因為cron把任何輸出都email到root的信箱了。

每兩個小時

0 */2 * * * echo “Have a break now.” >> /tmp/test.txt

晚上11點到早上8點之間每兩個小時,早上八點

0 23-7/2,8 * * * echo “Have a good dream:)” >> /tmp/test.txt

每個月的4號和每個禮拜的禮拜一到禮拜三的早上11點

0 11 4 * 1-3 command line

1月1日早上4點

0 4 1 1 * command line

每次編輯完某個用戶的cron設置后,cron自動在/var/spool/cron下生成一個與此用戶同名的文件,此用戶的cron信息都記錄在這個文件中,這個文件是不可以直接編輯的,只可以用crontab -e 來編輯。cron啟動后每過一份鐘讀一次這個文件,檢查是否要執行里面的命令。因此此文件修改后不需要重新啟動cron服務。

2、編輯/etc/crontab 文件配置cron

cron服務每分鐘不僅要讀一次/var/spool/cron內的所有文件,還需要讀一次/etc/crontab,因此我們配置這個文件也能運用 cron服務做一些事情。用crontab配置是針對某個用戶的,而編輯/etc/crontab是針對系統的任務。此文件的文件格式是:

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root //如果出現錯誤,或者有數據輸出,數據作為郵件發給這個帳號

HOME=/ //使用者運行的路徑,這里是根目錄

# run-parts

01 * * * * root run-parts /etc/cron.hourly //每小時執行/etc/cron.hourly內的腳本
02 4 * * * root run-parts /etc/cron.daily //每天執行/etc/cron.daily內的腳本
22 4 * * 0 root run-parts /etc/cron.weekly //每星期執行/etc/cron.weekly內的腳本
42 4 1 * * root run-parts /etc/cron.monthly //每月去執行/etc/cron.monthly內的腳本

大家注意”run-parts”這個參數了,如果去掉這個參數的話,后面就可以寫要運行的某個腳本名,而不是文件夾名了。
————————————–

基本格式 :
*  *  *  *  *  command
分 時 日 月 周 命令

第1列表示分鐘1~59 每分鐘用*或者 */1表示
第2列表示小時1~23(0表示0點)
第3列表示日期1~31
第4列表示月份1~12
第5列標識號星期0~6(0表示星期天)
第6列要運行的命令

crontab文件的一些例子:

30 21 * * * /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每晚的21:30重啟lighttpd 。

45 4 1,10,22 * * /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每月1、10、22日的4 : 45重啟lighttpd 。

10 1 * * 6,0 /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每周六、周日的1 : 10重啟lighttpd 。

0,30 18-23 * * * /usr/local/etc/rc.d/lighttpd restart
上面的例子表示在每天18 : 00至23 : 00之間每隔30分鐘重啟lighttpd 。

0 23 * * 6 /usr/local/etc/rc.d/lighttpd restart
上面的例子表示每星期六的11 : 00 pm重啟lighttpd 。

* */1 * * * /usr/local/etc/rc.d/lighttpd restart
每一小時重啟lighttpd

* 23-7/1 * * * /usr/local/etc/rc.d/lighttpd restart
晚上11點到早上7點之間,每隔一小時重啟lighttpd

0 11 4 * mon-wed /usr/local/etc/rc.d/lighttpd restart
每月的4號與每周一到周三的11點重啟lighttpd

0 4 1 jan * /usr/local/etc/rc.d/lighttpd restart
一月一號的4點重啟lighttpd

原文:http://www.cublog.cn/u/31547/showart_438018.html