北京网帮你
apche thikphp5自定义强制路由 File not found.
时间:2018-04-19 00:28:44 浏览:156

内容详情

1.开启配置config.php

'url_param_type' => 0,
// 是否开启路由
'url_route_on' => true,
// 路由使用完整匹配
'route_complete_match' => true,
// 路由配置文件(支持配置多个)
'route_config_file' => ['route'],
// 是否强制使用路由
'url_route_must' => true,

2.使用route.php;

use think\Route;
// 注册路由到index模块的News控制器的read操作
Route::get('/index','index/index/index');
Route::get('/dome','index/index/dome');

3.创建Index控制器index和dome方法;





  1     <?php
 2     namespace app\index\controller;
 3      
 4     use think\Controller;
 5     use GatewayClient\Gateway;
 6     use think\Route;
 7     class Index extends Controller
 8     {
 9         public function index()
 10         {
 11          
 12                 echo "321";
 13         }
 14           public function dome()
 15         {
 16             echo "123";
 17      
 18         }
 19      
 20      
 21     }
 22      


4.访问http://127.0.0.1/index

如果出现File not found. 请你修改.htaccess文件


  1       Options +FollowSymlinks
 2       RewriteEngine On
 3       RewriteCond %{REQUEST_FILENAME} !-d
 4       RewriteCond %{REQUEST_FILENAME} !-f
 5       RewriteRule ^(.*)${content}nbsp;index.php/$1 [QSA,PT,L]


改.为


  1      
 2      RewriteEngine on
 3      RewriteCond %{REQUEST_FILENAME} !-d
 4      RewriteCond %{REQUEST_FILENAME} !-f
 5      RewriteRule ^(.*)${content}nbsp;index.php?s=/$1 [QSA,PT,L]

[上一篇]手把手和我一起搭建腾讯云免费的s
[下一篇]composer 卸载github.com源码包
Copyright 2022 © 93580.com.cn 网帮你

2022 © 版权所有 红花岗区网帮你信息技术工作室

工信部备案号:黔ICP备2024036985号-2

请使用网帮你微信扫码登录