为了在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/"
需要加上 Rewriteba
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
Rewriteba
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
最佳答案
