Why is enabling REWRITE mode ineffective? Http: // localhost/app/index. php/Login in the address bar, you can enter a webpage
Http: // localhost/app/. in this way, the webpage cannot be found and the address bar is changed to http: // localhost/app/Login.
Enter http: // localhost/app/index. php/Login to display the webpage
PHP version 5.5 ThinkPHP version 3.12
The content in. htaccess is:
RewriteEngine on
RewriteCond % {REQUEST_FILENAME }! -D
RewriteCond % {REQUEST_FILENAME }! -F
RewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L]
LoadModule rewrite_module modules/mod_rewrite.so first # Removed, AllowOverride All also changed
'URL _ model' => 2 has been added to the config file.
Code:
Class IndexAction extends CommonAction {
Public function index (){
}
}
Header ('content-type: text/html; charset = utf-8 ');
// Public call non-execution class
Class CommonAction extends Action {
// Construct
Public function _ initialize (){
Echo 'script window. top. location. href = "'./index. php.'/Login"; script ';
}
}
Class LoginAction extends Action {
// Logon display page
Public function index (){
$ This-> display ('login ');
}
}
How can this problem be solved?
Reply to discussion (solution)
RewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L]
I changed this
RewriteRule ^ (. *) $ index. php? S = $1 [QSA, PT, L]
This is why
However, my online search is basically the first type. I only see that someone once said this and I cannot tell why.
This indicates that you have not enabled path_info.
What is your Apache version? Why not enable it by default?
How can I enable phpstudy2014 and Apache 2.4.10?
This eldest brother, I tried the online method. it seems that path_info has enabled
Hmm
Http: // localhost/app/index. php/Login, indicating that path_info is enabled.
So why not your RewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L?
This rewrite rule is
Http: // localhost/app/Login is changed to http: // localhost/app/index. php/Login.