ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 路由 ### 路由 系统支持URL重写 所有的生成链必须是 `<?=url("控制器/方法",数组参数)?>` 如 /index.php?ctl=Goods\_Goods&met=goodslist `<?=url('Goods_Goods/goodslist')?>` 必须是以这种形式输出 如果有参数则第二个参数是数组,如id=100这种,应写成 `<?=url('Goods_Goods/goodslist',['id'=>100])?>` 要支持URL重写,请在.htaccess 加入以下代码,系统已加入。用户无需再次添加 ``` <pre class="calibre14">``` Options <span class="token">+</span>FollowSymLinks IndexIgnore <span class="token">*</span><span class="token5">/* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php </span> ``` ``` Url规则配置请在`configs/route.ini.php`中配置, 需要对正则表达式有一定的了解,以下是部分路由规则事例。 ``` <pre class="calibre15">``` <span class="token5">/** * Here You can setting routes * 用户自己设置路由,此处需要设置 */</span> $routes <span class="token">=</span> <span class="token1">[</span> <span class="token4">'goods'</span><span class="token">=</span><span class="token">></span><span class="token4">"Goods_Goods@goodslist"</span><span class="token1">,</span> <span class="token4">'goods/<cat_id:\d+>'</span><span class="token">=</span><span class="token">></span><span class="token4">"Goods_Goods@goodslist"</span><span class="token1">,</span> <span class="token4">'goods/<type:\w+>/<gid:\d+>'</span><span class="token">=</span><span class="token">></span><span class="token4">"Goods_Goods@goods"</span><span class="token1">,</span> <span class="token4">'shop/<id:\d+>'</span><span class="token">=</span><span class="token">></span><span class="token4">"Shop@index"</span><span class="token1">,</span> <span class="token4">'brand'</span><span class="token">=</span><span class="token">></span><span class="token4">"Goods_Brand@index"</span><span class="token1">,</span> <span class="token4">'brand/<brand_id:\d+>'</span><span class="token">=</span><span class="token">></span><span class="token4">"Goods_Brand@brandList"</span><span class="token1">,</span> <span class="token1">]</span><span class="token1">;</span> ``` ```