请问下REWRITE模式开启为什么会没有作用?

原创
2016-06-23 13:22:00 584浏览

http://localhost/app/index.php/Login 在地址栏输入可以出现网页
http://localhost/app/ 这样输入提示无法找到该网页 然后地址栏变成http://localhost/app/Login

http://localhost/app/index.php/Login 这样输入可以出现网页

PHP的版本是5.5 ThinkPHP版本是3.12

.htaccess 里面的内容为 :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]


LoadModule rewrite_module modules/mod_rewrite.so前面#号去掉了,AllowOverride All也改了

config配置文件里面 已经添加 'URL_MODEL' => 2

代码为:
class IndexAction extends CommonAction {
public function index(){

}
}

header('Content-type:text/html;charset=utf-8');
//公共调用非执行类
class CommonAction extends Action{

//构造函数 __construct
public function _initialize(){
echo '';

}
}

class LoginAction extends Action {

//登录展示页
public function index(){

$this->display('login');
}
}

请问要怎么解决呢


回复讨论(解决方案)

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


我把这个改成

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

这样居然出来了

但是我网上搜索基本上都是第一种这样的,只看到一次有人说改成这样 而且说不出为什么

这说明你没有开启 path_info
你的 Apache 是什么版本的?为什么不是默认开启

请问要怎么开启呢 我下的是phpstudy2014 Apache是2.4.10的版本

这位大哥,我试了试网上的方法,好像 path_info已经开启了的


http://localhost/app/index.php/Login 可以,表示 path_info 是开启的

那么你的 RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 为何不行呢?
这条重写规则就是将
http://localhost/app/Login 变成 http://localhost/app/index.php/Login 去执行的

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。