我這次重做cms,預備所有的鏈接按照下面方式作
http://localhost/index.Html
http://localhost/cms/news/index.html 列出所有新聞
http://localhost/cms/news/index1.html 翻頁
http://localhost/cms/news/20060410/n000000001.html 列出具體一條
http://localhost/cms/news/xjxjynews/index.html 可以繼續往下加
http://localhost/cms/xxjj/index.html
http://localhost/cms/xxjj/xxld/index.html
http://localhost/cms/xxjj/xxld/about.html
整個節點按樹狀延生
所有/cms的下面都被攔截,然后根據URI調用相應模板
也就說/cms下面的路徑都是虛假的,都不是服務器上的實際路徑
而且這樣的鏈接便于被搜索。便于用squid作前置緩存。便于隱藏實際后臺實現
統一的入口也便于預防黑客攻擊,防止例如 ../.。 或者 sql注入
假如使用php,實現的方法是使用URL復寫
# BEGIN ITSCMS RESTRICTIONS然后解析URL
function get_url_params( $base_url)
{
$request = substr( $_SERVER['REQUEST_URI'], strlen( $base_url));
if( substr( $request, -1) == '/')
$request = substr( $request, 0, -1);
return eXPlode( '/', $request);
}
假如用java實現
用/cms/* 實際上是轉到servlet
使用 HttpServletRequest req
String pathInfo = req.getPathInfo() ;
然后解析路徑
新聞熱點
疑難解答