Hidden index.php,thinkphpindex.php in thinkphp frame
The configuration written in this article has been tested on ThinkPHP3.2.2. Other versions are supposedly compatible.
First modify the configuration file:
' Url_case_insensitive ' + true,//default false means URL is case-sensitive true indicates case insensitive
' Url_model ' + 2,//URL access mode, optional parameters 0, 1, 2, 3, representing the following four modes:
0 (normal mode); 1 (PATHINFO mode); 2 (REWRITE mode); 3 (Compatibility mode) defaults to PathInfo mode
Nginx
Recommended:
Location/{try_files $uri $uri//index.php?s= $uri & $args;}
This means: If the first $uri does not exist, access the $uri/, and if $uri/does not already exist, Access/index.php?s= $uri & $args. Can be followed by a lot of.
Try_files syntax: try_files file1 [file2 ... filen] Fallback default: no scope: Location
Again for example:
What do you mean? URI can not be successfully accessed, well, then give you a 404.
But most of the articles found online are configured in this way:
Location/{if (!-e $request _filename) {rewrite ^/(. *) $/index.php?/$1 last;break;}}
is not actually feasible.
Apache
Create a new. htaccess file in the root directory:
Options +followsymlinksrewriteengine onrewritecond%{request_filename}!-drewritecond%{request_filename}!- Frewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]
IIS Environment
If your server environment supports Isapi_rewrite, you can configure the Httpd.ini file to add the following:
Rewriterule (. *) $/index\.php\?s=$1 [I]
Under high versions of IIS, you can configure Web. config to add rewrite nodes in the middle:
Appendix
Nginx Full configuration text
Test.com.confserver{listen 80;server_name test.com;index index.php index.html;root/wwwroot/test.com/;# unless the Request is for a valid file (image, JS, CSS, etc), send to Bootstraplocation/{try_files $uri $uri//index.php?s= $uri &am p; $args;} Location ~ \.php{fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php; #fastcgi_param script_filename/scripts$fastcgi _script_name, #fastcgi_param script_filename $document _root$fastcgi_script_name;include Fastcgi_params;set $path _ Info ""; set $real _script_name $fastcgi _script_name;if ($fastcgi _script_name ~ "^ (. +?\.php) (/.+) $") {set $real _script_ Name $1;set $path _info;} Fastcgi_param script_filename $document _root$real_script_name;fastcgi_param script_name $real _script_name;fastcgi_ param path_info $path _info;} Location/status {stub_status on;access_log off;} Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) ${expires 24h;} Location ~. *\. (js|css)? ${expires 12h;} if ($fastcgi _script_name ~ \.. *\/.*php) {return 403;} Access_log Logs/test.com_access.log Main;Error_log logs/test.com_error.log notice;}
Articles you may be interested in:
- Modify Apache config file to remove index.php from thinkphp URL
- Nginx configuration pathinfo Hidden thinkphp index.php
http://www.bkjia.com/PHPjc/1119964.html www.bkjia.com true http://www.bkjia.com/PHPjc/1119964.html techarticle hidden in the thinkphp frame index.php,thinkphpindex.php the configuration written in this article has been tested on ThinkPHP3.2.2. Other versions are supposedly compatible. First modify the configuration file: ' Url_case_insens ...