ThinkPHP去除url中的index.php
例如你的原路径是 http://localhost/test/index.php/index/add
那么现在的地址是 http://localhost/test/index/add
那么现在的地址是 http://localhost/test/index/add
如何去掉index.php呢?
一.apache 设置
1.httpd.conf配置文件中加载了mod_rewrite.so模块
#LoadModule rewrite_module modules/mod_rewrite.so
2.AllowOverride None 讲None改为 All
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
AllowOverride All
Order deny,allow
Deny from all
</Directory>
二、确保URL_MODEL设置为2,在项目的配置文件里写
return Array(
'URL_MODEL' => '2',
);
'URL_MODEL' => '2',
);
三、htaccess文件必须放到跟目录下 这个文件里面加:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
前望