<div class="truth">
BUG是程序员晋级的灵石!
</div>
<blockquote class="default">
<p>知识点<br>
1.在apache 常规坏境下隐藏index.php<br>
2.在apache phpstudy隐藏index.php<br>
3.Nginx下隐藏index.php<br>
</p>
<p>注意:这里不讲iis下的隐藏</p>
<div class="env">版本:thinkphp5.07</div>
</blockquote>
<div class="step">1.常规apache隐藏index.php</div>
<div class="info">
<p>本方法同样适用于wamp2.4 (注意:wamp2.5 apache语法规则有变化,因为apache版本比较高),xampp等环境。
</p>
</div>
~~~
<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>
//如果以上方法不成立,可以尝试下面的方法(高版本apache)
<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>
~~~
<div class="step">2.phpstudy隐藏index.php</div>
~~~
<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>
~~~
<div class="step">3.Nginx环境下配置</div>
~~~
location / { // …..省略部分代码
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
~~~