去掉url中的index.php,让url彻底mvc。
1.httpd.conf配置文件中加载了mod_rewrite.so模块 //在APACHE里面去配置
1
<code>#LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉</code>
2.AllowOverride None 将None改为 All //在APACHE里面去配置 (注意其他地方的AllowOverride也统统设置为ALL)
2
3
4
5
6
7
8
9
10
11
<code><Directory </code><code>"D:/server/apache/cgi-bin"</code><code>></code>
<code>AllowOverride none 改 AllowOverride ALL</code>
<code>Options None</code>
<code>Order allow,deny</code>
<code>Allow from all</code>
<code></Directory></code>
3.确保URL_MODEL设置为2,在项目的配置文件里写
<code>return</code> <code>Array(</code>
<code> </code><code>'URL_MODEL'</code> <code>=> </code><code>'2'</code><code>,</code>
<code>);</code>
4 .htaccess文件必须放到跟目录下
这个文件里面加:
<code><</code><code>IfModule</code> <code>mod_rewrite.c></code>
<code>RewriteEngine on</code>
<code>RewriteCond %{REQUEST_FILENAME} !-d</code>
<code>RewriteCond %{REQUEST_FILENAME} !-f</code>
<code>RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</code>
<code></</code><code>IfModule</code><code>></code>
补充:在windows下不能建立以点开头的文件,你可以先随便建立一个文件
然后在DOS在操作
<code>rename xxxx.xxxx .htaccess</code>
<code></code><code></code>
<code></code><code>本文转自 virusswb 51CTO博客,原文链接:http://blog.51cto.com/virusswb/1530090,如需转载请自行联系原作者</code>
<code></code>