thinkphp5 隐藏index.php方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012972536/article/details/78197479

在使用thinkphp 5开发restful API时经常会遇到路由配置问题。那么如何在隐藏请求URL中的index.php,让请求地址更加美观呢?

解决方法如下,在项目根目录新建 .htaccess文件,写入以下内容:


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

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


猜你喜欢

转载自blog.csdn.net/u012972536/article/details/78197479