ThinkPHP去除url中的index.php以及绑定模块

来源:互联网 发布:mac qq离线发送 编辑:程序博客网 时间:2024/05/27 08:13


例如你的原路径是         http://localhost/index.php/home/index/index
你想要的访问的地址是  http://localhost/home/index/index


也就是去除index.php,方法如下:



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


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


2.AllowOverride None 将None改为 All      //在APACHE里面去配置 


AllowOverride none  改   AllowOverride ALL(包括httpd.conf 和 httpd_vhost.conf中的)

Options None
Order allow,deny
Allow from all

3.确保URL_MODEL设置为2,(ThinkPHP/Conf/convention.php 第136行)
   'URL_MODEL' => '2',
);


4 .htaccess文件必须放到跟目录下
这个文件里面加:


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]


5.重启wamp


绑定模块

原地址: http://localhost/home/index/index

现地址: http://localhost/index/index

入口文件中添加define('BIND_MODULE','Admin'); 

0 0
原创粉丝点击