房屋裝潢設計新選擇!多年經驗 細膩打造,,價格合理 | 搬家優質選!專業服務品質,細心保護物品 精緻包裝服務,提供南北長途搬家 |
Apache/2.0 下設定mod_rewrite |
房東:小蛙 發表時間:2007-02-01 | [檢舉] |
Apache/2.0 設定方法如下 再搜尋以下的文字 AllowOverride None 把它變更為 AllowOverride All 即可 # AllowOverride controls what directives may be placed in .htaccess files. # It can be \"All\", \"None\", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All 在這裡舉 PHPBB2 2.0.3 的例子來說,一步一步來: 1. 把 Apache 的 Rewrite 打開(mod_rewrite) 2. 在 phpbb/include/page_header.php 的 // Generate logged in/logged out status 之前加入 代碼: ob_start(); function replace_for_mod_rewrite(&$s) { $urlin = array( \"\'(? \"\'(? \"\'(? \"\'(? \"\'(? \"\'(? \"\'(? \"\'(? \"\'(? \"\'(? ); $urlout = array( \"viewforum-$1-$2-$3.html\", \"forum-$1.html\", \"forum-$1.html\", \"prev-topic-$1.html\", \"next-topic-$1.html\", \"viewtopic-$1-$2-$3-$4.html\", \"viewtopic-$1-$2.html\", \"viewtopic-$1.html\", \"viewpost-$1.html\", \"profile-$1.html\" ); $s = preg_replace($urlin, $urlout, $s); $s = mb_ereg_replace( \"viewtopic-([0-9]+).html&(.*)$\", \"viewtopic.php?t=\\\\1&\\\\2\", $s); return $s; } 3. 在 phpbb/include/page_tail.php 代碼: 在下列之後: $db->sql_close(); 加入: $contents = ob_get_contents(); ob_end_clean(); echo replace_for_mod_rewrite($contents); global $dbg_starttime; 在下列之後: ob_end_clean(); 加入: echo replace_for_mod_rewrite($contents); global $dbg_starttime; 4. 接下來當然要建立 .htaccess 的 rewrite rule 代碼: RewriteEngine On RewriteRule ^viewforum-([0-9a-zA-Z]+)-([0-9]+)-([0-9]+)\\.html$ viewforum.php?f=$1&topicdays=$2&start=$3 RewriteRule ^forum-([0-9a-zA-Z]+)\\.html$ viewforum.php?f=$1&mark=topic RewriteRule ^forum-([0-9a-zA-Z]+)\\.html$ viewforum.php?f=$1 RewriteRule ^prev-topic-([0-9]+)\\.html$ viewtopic.php?t=$1&view=previous RewriteRule ^next-topic-([0-9]+)\\.html$ viewtopic.php?t=$1&view=next RewriteRule ^viewtopic-([0-9]+)-([0-9]+)\\.html$ viewtopic.php?t=$1&start=$2 RewriteRule ^viewtopic-([0-9]+)-([0-9]+)-([a-zA-Z]*)-([0-9]+)\\.html$ viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 RewriteRule ^viewtopic-([0-9]+)\\.html$ viewtopic.php?t=$1 RewriteRule ^viewpost-([0-9]+)\\.html$ viewtopic.php?p=$1 RewriteRule ^viewtopic-([0-9]+)\\.html&highlight=(.*)$ viewtopic.php?t=$1&highlight=$2 RewriteRule ^profile-([0-9]+)\\.html$ profile.php?mode=viewprofile&u=$1 5. 測試∼ 當然 OK; 再分享一下 Linka 的 rewrite .htaccess 代碼: RewriteEngine On RewriteBase /linka/ RewriteRule ^category/([0-9]+)\\.html$ http://vovo2000.com/linka/links.php?cat=$1 [QSA] RewriteRule ^action/([a-z0-9]+)\\.html$ http://vovo2000.com/linka/links.php?action=$1 [QSA] RewriteRule ^view/([a-z0-9]+)/([0-9]+)\\.html$ http://vovo2000.com/linka/links.php?action=$1&link_id=$2 [QSA] RewriteRule ^adminvlink/$ http://vovo2000.com/linka/ [R] //開啟輸出緩衝 ob_start (); //輸出網頁 echo << docOut; //取得輸出緩衝內容 $docOut = ob_get_contents (); //關閉輸出緩衝 ob_end_clean (); $search[] = \'/bbs.php\\?id=([[:digit:]]*)/is\'; $modify[] = \'bbs_\\1.html\'; echo preg_replace ($search, $modify, $docOut); ?> $search[] = \'/j2h.php\\?id=([0-9]+)/is\'; http://www.phpx.com/happy/viewthread.php?tid=56135 http://us2.php.net/ob_start $urlin = array( \"\'(? \"\'(? ); $urlout = array( \"j2h-$1.html\", \"index-$1-$2.html\", ); echo preg_replace ($urlin, $urlout, $docOut); RewriteEngine On RewriteRule ^([0-9]+)\\.html$ j2h.php?id=$1 ............................ //開啟輸出緩衝 ob_start (); //輸出網頁 echo << docOut; //取得輸出緩衝內容 $docOut = ob_get_contents (); //關閉輸出緩衝 ob_end_clean (); $search[] = \'/bbs.php\\?id=([[:digit:]]*)/is\'; $modify[] = \'bbs_\\1.html\'; echo preg_replace ($search, $modify, $docOut); ?> |
廣利不動產-新板特區指名度最高、值得您信賴的好房仲 您的托付,廣利用心為您服務 廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲 完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心! |
1 樓住戶:jjj 發表時間:2007-02-04 | [檢舉] |
.htaccess RewriteEngine On RewriteRule ^([0-9]+)\.html$ j2h.php?id=$1 RewriteRule ^index-([0-9]+)-([0-9]+)\.html$ index.php?show=$1&page=$2 RewriteRule ^j2h-([0-9]+)-([0-9]+)\.html$ j2h.php?id=$1&show=$2 RewriteRule ^index2-([0-9]+)-([0-9a-zA-Z]+)-([0-9]+)\.html$ index2.php?show=$1&board=$2&page=$3 .............................. INDEX.PHP //開啟輸出緩衝 ob_start (); //取得輸出緩衝內容 $docOut = ob_get_contents (); //關閉輸出緩衝 ob_end_clean (); $urlin = array( "'(? "'(? ); $urlout = array( "$1.html", "index-$1-$2.html", ); echo preg_replace ($urlin, $urlout, $docOut); ?> ........................ index2.php //取得輸出緩衝內容 $docOut = ob_get_contents (); //關閉輸出緩衝 ob_end_clean (); $urlin = array( "'(? "'(? ); $urlout = array( "$1.html", "index2-$1-$2-$3.html", ); echo preg_replace ($urlin, $urlout, $docOut); ................................................... J2H.PHP //開啟輸出緩衝 ob_start (); //取得輸出緩衝內容 $docOut = ob_get_contents (); //關閉輸出緩衝 ob_end_clean (); $urlin = array( "'(? ); $urlout = array( "j2h-$1-$2.html", ); echo preg_replace ($urlin, $urlout, $docOut); |