thinkphp5默认设置的.htaccess文件实现了去掉(隐藏)index.php的功能,但是在phpstudy(apache)中运行thinkphp5时却无法正常去掉index.php,错误的原因是在phpstudy中thinkphp5官方的.htaccess文件无效,解决办法 修改 public下的.htaccess文件
在使用phpstudy(apache)运行thinkphp5时,需要修改public下的.htaccess文件,才能正常去掉index.php。以下是修改后的代码:
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
将原来的代码注释掉,添加新的代码即可。在csdn上发布时,可以直接复制以上代码,粘贴到文章中即可。