tp5路由訪問的index.php如何隱藏,接口路由配置

1.將public下的文件.htaccess文件代碼修改如下  : 在index.php加問號?即可

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>

接口路由配置 :

這樣我們由原先的路徑

http://api.test-api.com/index.php/api/user

改爲

http://api.test-api.com/api/user

補充:關於api 路由編寫配置:api.test-api.com/user/index

1.app下的config.php裏  設置開啓爲true  ->即將路由開啓!!

    // 是否開啓路由
    'url_route_on'           => true,

2.app下的route.php裏

// api.test-api.com => www.test-api.com/index.php/api
// 
Route::domain('api','api');

// api.test-api.com/user/2 => www.test-api.com/index.php/api/user/index/id/2
Route::rule('user/:id','user/index');


Route::rule('/','index/index/index');

 

形如:

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章