修改apache配置文件去除thinkphp url中的index.php

2015-01-24信息快讯网

这篇文章主要介绍了修改apache配置文件去除thinkphp url中的index.php的方法,大家参考使用吧

例如你的原路径是 http://localhost/test/index.php/index/add
那么现在的地址是 http://localhost/test/index/add
如何去掉index.php呢?

1、httpd.conf配置文件中加载了mod_rewrite.so模块  //在APACHE里面去配置

#LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉

2、AllowOverride None 讲None改为 All      //在APACHE里面去配置 (注意其他地方的AllowOverride也统统设置为ALL)

<Directory "D:/server/apache/cgi-bin">
AllowOverride none  改   AllowOverride ALL
Options None
Order allow,deny
Allow from all
</Directory>

3、确保URL_MODEL设置为2,在项目的配置文件里写

return Array(
   'URL_MODEL' => '2',
);

4 、.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

PHP中遇到BOM、<feff>编码导致json_decode函数无法解析问题
浅析ThinkPHP的模板输出功能
ThinkPHP中的系统常量和预定义常量集合
ThinkPHP实现多数据库连接的解决方法
ThinkPHP快速入门实例教程之数据分页
ThinkPHP框架实现session跨域问题的解决方法
PHP使用GIFEncoder类处理gif图片实例
PHP使用GIFEncoder类生成gif动态滚动字幕
PHP使用GIFEncoder类生成的GIF动态图片验证码
ThinkPHP模板判断输出Defined标签用法详解
编译PHP报错configure error Cannot find libmysqlclient under usr的解决方法
Zend Framework页面缓存实例
非常好用的Zend Framework分页类
PHP获取windows登录用户名的方法
PHP错误Parse error: syntax error, unexpected end of file in test.php on line 12解决方法
windows下配置apache+php+mysql时出现问题的处理方法
教你如何在CI框架中使用 .htaccess 隐藏url中index.php
windwos下使用php连接oracle数据库的过程分享
PHP登陆后跳转到登陆前页面实现思路及代码
php使用curl访问https示例分享
windows下PHP_intl.dll正确配置方法(apache2.2+php5.3.5)
PHP类继承 extends使用介绍
codeigniter框架批量插入数据
ini_set的用法介绍
浅析ThinkPHP中的pathinfo模式和URL重写
php Calender(日历)代码分享
codeigniter使用技巧批量插入数据实例方法分享
php输入流php://input使用示例(php发送图片流到服务器)
zend framework文件上传功能实例代码
php制作unicode解码工具(unicode编码转换器)代码分享
linux实现php定时执行cron任务详解
php calender(日历)二个版本代码示例(解决2038问题)
PHP PDOStatement:bindParam插入数据错误问题分析
PHP imagegrabscreen和imagegrabwindow(截取网站缩略图)的实例代码
怎么在Windows系统中搭建php环境
在windows平台上构建自己的PHP实现方法(仅适用于php5.2)
©2014-2024 dbsqp.com