Hide index. php and thinkphpindex. php_PHP in the ThinkPHP framework.

Source: Internet
Author: User
The ThinkPHP framework hides index. php and thinkphpindex. php. The ThinkPHP framework hides index. php and thinkphpindex. php. the configuration written in this article has been tested on ThinkPHP3.2.2. It is also compatible with other versions. First, modify the configuration file URL_CASE_INSENS ThinkPHP to hide index. php and thinkphpindex. php.

The configurations written in this article have been tested on ThinkPHP3.2.2. It is also compatible with other versions.

First, modify the configuration file:

'URL _ CASE_INSENSITIVE '=> true, // The default value is false, indicating that the URL is case-sensitive. true indicates that the URL is case-insensitive.
'URL _ model' => 2, // URL access mode. optional parameters: 0, 1, 2, and 3, which represent the following four modes:
// 0 (normal mode); 1 (PATHINFO mode); 2 (REWRITE mode); 3 (compatible mode): PATHINFO mode by default

Nginx

Recommended:

location / {try_files $uri $uri/ /index.php?s=$uri&$args;}

If the first $ uri does not exist, access $ uri/. if $ uri/does not exist, Access/index. php? S = $ uri & $ args. It can be followed by many.

Try_files syntax: try_files file1 [file2... filen] fallback default value: No scope: location

For example:

try_files $uri = 404 

What does it mean? The uri cannot be accessed successfully. well, you can get 404.

However, most of the articles found on the Internet are configured as follows:

location / {if (!-e $request_filename) {rewrite ^/(.*)$ /index.php?/$1 last;break;}}

Actually not feasible.

Apache

Create a. 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 and add the following content:
RewriteRule (. *) $/index \. php \? S = $1 [I]

In the later version of IIS, you can configure web. Config and add a rewrite node in the middle:

 
  
   
    
    
   
  
  

Appendix

Complete Nginx configuration

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&$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 $2;}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 configuration file to remove index. php from thinkphp url
  • Nginx configure PATHINFO to hide thinkphp index. php

Configurations written in this article have been tested on ThinkPHP3.2.2. It is also compatible with other versions. First modify the configuration file: 'URL _ CASE_INSENS...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.