How does ThinkPHP hide index.php files
This article introduces the knowledge of "how to hide index.php files in ThinkPHP". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Take Apache as an example, you need to add the .htaccess file at the same level of the entry file (it comes with the official default), as follows:
Options + FollowSymlinks-MultiviewsRewriteEngine onRewriteCond% {REQUEST_FILENAME}!-dRewriteCond% {REQUEST_FILENAME}!-fRewriteRule ^ (. *) $index.php/$1 [QSA,PT,L]
If you use phpstudy, the rules are as follows:
Options + FollowSymlinks-Multiviews RewriteEngine on RewriteCond% {REQUEST_FILENAME}!-d RewriteCond% {REQUEST_FILENAME}!-f RewriteRule ^ (. *) $index.php
If the index.php file is stored in public, the rules are as follows:
Options + FollowSymlinks-Multiviews RewriteEngine on RewriteCond% {REQUEST_FILENAME}!-d RewriteCond% {REQUEST_FILENAME}!-f RewriteRule ^ (. *) $public/index.php
Next, you can access it using the following URL address
Http://tp5.com/index/index/indexhttp://tp5.com/index/index/hello
If the version of apache you are using does not properly hide index.php using the above method, try configuring the .htaccess file in the following way:
Options + FollowSymlinks-MultiviewsRewriteEngine onRewriteCond% {REQUEST_FILENAME}!-dRewriteCond% {REQUEST_FILENAME}!-fRewriteRule ^ (. *) $index.php?/$1 [QSA,PT,L]
If it is a Nginx environment, you can add to Nginx.conf:
Location / {/ /... .. Omit part of the code if (!-e $request_filename) {rewrite ^ (. *) $/ index.php?s=/$1 last; break;}} vhosts-confserver {listen 80; server_name xhb.com www.xhb.com; root "F:/project/xhb"; location / {index index.html index.htm index.php If (!-e $request_filename) {rewrite ^ (. *) $/ index.php?s=/$1 last; break;} # autoindex on;} location ~\ .php (. *) ${fastcgi_pass 127.0.0.1 rewrite 9000; fastcgi_index index.php Fastcgi_split_path_info ^ ((? U). +\ .php) (/?. +) $; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params;}}
This is the end of the content of "how to hide index.php files in ThinkPHP". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!