关于ThinkPHP5的public/.htaccess文件

浏览:8918 发布日期:2017/09/08 分类:技术分享

为了在url中隐藏index.php,需要写 RewriteRule

查看phpinfo() 打印的Server API: Apache 2.0 Handler
查看phpinfo() 打印的Server API: CGI/FastCGI

==================================================================
默认的:

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
==================================================================
如果为 Server API: CGI/FastCGI 需要修改为:

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
==================================================================
如果 Apache 的配置文件中使用 Alias 映射访问目录
Alias /sports "D:/WorkSpace/Sports/public/"
需要加上 Rewritebase /sports
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
Rewritebase /sports
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
最佳答案
评论( 相关
后面还有条评论,点击查看>>