ThinkPHP -- 去除URL中的index.php
2013-10-15 12:42
281 查看
原路径是 http://localhost/test/index.php/index/add
想获得的地址是 http://localhost/test/index/add
那么如何去掉index.php呢? @_@!!
(1)apache 设置
httpd.conf配置文件中加载了mod_rewrite.so模块
AllowOverride None 讲None改为 All
(2)确保URL_MODEL设置为2,在项目的配置文件config.php里
(3)添加.htaccess文件,并添加如下代码,必须放到项目根目录下
补充:在windows下不能建立以点开头的文件,你可以先随便建立一个文件
然后在DOS在操作 rename xxxx.xxxx .htaccess
或者打开记事本写入htaccess然后另存为.htaccess即可
如果出现403错误则将.htaccess打开在开头添加Options +FollowSymLinks
即如下所示:
即可解决。
无权限也是加上Options +FollowSymLinks
相关链接:/article/6360514.html
/article/5820800.html
想获得的地址是 http://localhost/test/index/add
那么如何去掉index.php呢? @_@!!
(1)apache 设置
httpd.conf配置文件中加载了mod_rewrite.so模块
LoadModule rewrite_module modules/mod_rewrite.so
AllowOverride None 讲None改为 All
<Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Deny from all </Directory>
(2)确保URL_MODEL设置为2,在项目的配置文件config.php里
return Array( …… 'URL_MODEL' => '2', …… );
(3)添加.htaccess文件,并添加如下代码,必须放到项目根目录下
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>
补充:在windows下不能建立以点开头的文件,你可以先随便建立一个文件
然后在DOS在操作 rename xxxx.xxxx .htaccess
或者打开记事本写入htaccess然后另存为.htaccess即可
如果出现403错误则将.htaccess打开在开头添加Options +FollowSymLinks
即如下所示:
Options +FollowSymLinks
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>
即可解决。
无权限也是加上Options +FollowSymLinks
相关链接:/article/6360514.html
/article/5820800.html
相关文章推荐
- ThinkPHP去除url中的index.php 之设置WAMP
- ThinkPHP去除url中的index.php
- ThinkPHP去除url中的index.php
- Thinkphp中去除URL里的index.php
- Thinkphp中去除URL里的index.php
- 修改apache配置文件去除thinkphp url中的index.php
- ThinkPHP去除url中的index.php以及绑定模块
- ThinkPHP去除url中的index.php
- 修改apache配置文件去除thinkphp url中的index.php
- ThinkPHP去除url中的index.php
- 修改apache配置文件去除thinkphp url中的index.php
- 修改apache配置文件去除thinkphp url中的index.php
- ThinkPHP去除url中的index.php 之设置WAMP
- ThinkPHP去除url中的index.php
- ThinkPHP去除url中的index.php
- ThinkPHP去除url中的index.php
- ThinkPHP去除url中的index.php
- 修改apache配置文件去除thinkphp url中的index.php
- 修改apache配置文件去除thinkphp url中的index.php
- thinkphp 如何去除url中的index.php