原文链接
Apache 特有的 rewrite 技术很好用,Vovo2000.Com 的
/gallery/
/vovo-gallery/
/phpbb2/
/linka/
...
都已经彻底嵌入 rewrite。 Rewrite 很简单的说,就是把类似
==> /phpbb2/viewtopic.php?t=1388&start=0
动态网页,转成
==> /phpbb2/viewtopic-1388-0.html
好处有:
1. URL 短一点,静态网址的接受度较高。
2. Search Engine 比较吃的下去~
3. 静态的网址会有比较好的 SE-BENCHMARK
===========================================
===========================================
在这里举 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
代码:
在下列?#123;式之后:
$db->sql_close();
?#91;入:
$contents = ob_get_contents();
ob_end_clean();
echo replace_for_mod_rewrite($contents);
global $dbg_starttime;
在下列?#123;式之后:
ob_end_clean();
?#91;入:
echo replace_for_mod_rewrite($contents);
global $dbg_starttime;
Apache 特有的 rewrite 技术很好用,Vovo2000.Com 的
/gallery/
/vovo-gallery/
/phpbb2/
/linka/
...
都已经彻底嵌入 rewrite。 Rewrite 很简单的说,就是把类似
==> /phpbb2/viewtopic.php?t=1388&start=0
动态网页,转成
==> /phpbb2/viewtopic-1388-0.html
好处有:
1. URL 短一点,静态网址的接受度较高。
2. Search Engine 比较吃的下去~
3. 静态的网址会有比较好的 SE-BENCHMARK
===========================================
===========================================
在这里举 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
代码:
在下列?#123;式之后:
$db->sql_close();
?#91;入:
$contents = ob_get_contents();
ob_end_clean();
echo replace_for_mod_rewrite($contents);
global $dbg_starttime;
在下列?#123;式之后:
ob_end_clean();
?#91;入:
echo replace_for_mod_rewrite($contents);
global $dbg_starttime;
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




