The URL of the app developed with thinkphp usually takes a index.php, and if we need pseudo-static or SEO optimization, this is very bad to see and meaningless. So how do we get rid of the index.php in the Thinkphp app URL?
For this problem we can be resolved by URL rewrite, of course, this is required to open the Server Url_rewrite module. So make sure your server is turned on or open url_rewrite before following the steps below.
(1) If Url_rewrite is not turned on, you will need to find the httpd.conf in Apache and find the following line:
#LoadModule Rewrite_module modules/mod_rewrite.so
Remove the warning from the front and continue to find the following sentence:
AllowOverride None
Change all the found above statements to: allowoverride all
The above modifications are complete and then the Apache server can be restarted.
(2) Create a new. htaccess file under the app's root directory. Add the following code to the file:
Rewriteengine Onrewritecond%{request_filename}!-drewritecond%{request_filename}!-fRewriteRule ^ (. *) $ index.php/$1 [Qsa,pt,l]
In fact, the above has been implemented to remove the URL in the index.php character direct access to the application. But the only two-step operation will also be a problem is the thinkphp constant __url__ or will automatically take index.php this string, the solution to the problem is to add a configuration file in the project as follows:
' Url_model ' = ' 2 '
At this point the thinkphp app URL index.php completely disappeared.
Note: You cannot build directly under Windows. htaccess such a file, you can create a file (for example: Www.phpernote.com.txt), and then enter the following command in DOS:
Rename Www.phpernote.com.txt. htaccess
Articles you may be interested in
- How to remove the index.php string from the URL of the website CodeIgniter developed
- PHP to add a backslash in front of the reason and PHP to remove the backslash method, three ways to close the PHP magic quotes
- Summary of system constants in the thinkphp Action controller
- thinkphp print the last SQL statement
- The difference between execute and query methods in thinkphp
- PHP BOM Removal tool, PHP batch removal of BOM code
- The last record in the thinkphp template that determines the volist loop
- thinkphp like query
http://www.bkjia.com/PHPjc/764144.html www.bkjia.com true http://www.bkjia.com/PHPjc/764144.html techarticle The URL of the app developed with thinkphp usually takes a index.php, and if we need pseudo-static or SEO optimization, this is very bad to see and meaningless. So ...