URL路由在nginx下的配置

浏览:11313 发布日期:2014/04/09 分类:求助交流 关键字: URL路由 URL重写 nginx
'URL_MODEL' => 2,
  'URL_HTML_SUFFIX' => '.html',
  'URL_ROUTER_ON' => true,
  'URL_ROUTE_RULES' => 
  array (
    'article/:aid\d' => 'Article/detail',
    'category/:cid\d' => 'Article/index',
    'category' => 'Article/index',
    'page/:alias' => 'Page/index',
    'product/:pid\d' => 'Product/detail',
    'products/:cid\d' => 'Product/index',
    'products' => 'Product/index',
  ),
重写URL路由规则,本地windows+apache下可用。服务器端(LNMP)该怎么配置?

======================结贴,已经解决rewrite ^/products$ /index.php?m=Product&a=index;
rewrite ^/products/([0-9]+).html$ /index.php?m=Product&a=index&cid=$1;
rewrite ^/product/([0-9]+).html$ /index.php?m=Product&a=detail&pid=$1;
rewrite ^/category/([0-9]+).html$ /index.php?m=Article&a=index&cid=$1;
rewrite ^/category$ /index.php?m=Article&a=index;
rewrite ^/article/([0-9]+).html$ /index.php?m=article&a=detail&aid=$1;
rewrite ^/page/([a-z0-9_]+).html$ /index.php?m=Page&a=index&alias=$1;

if ($http_host ~* "^abcd.com"){
    set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
    rewrite ^/(.*)$ http://www.abcd.com/$1 permanent;
}
if (!-d $request_filename){
    set $rule_1 1$rule_1;
}
if (!-f $request_filename){
    set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
    rewrite ^/(.*)$ /index.php/$1 last;
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>