thinkphp3.2.3 How to change only one delimiter in the address URL, the other remains the same
Today we teach you a way to change only one delimiter in an address URL by using thinkphp3.2.3, and first look at this address!
Its original address should be/home/index/index/page/2.html, then how do we change the page after the/symbol to the _ symbol?
One, streamline address URL
In fact thinkphp originally with U () function to print out the address should be such/index.php/home/index/index.html, then we should talk about the index.php removal, so not only the address is beautiful and conducive to seo! We find the localhost/application/common/conf/config.php file and open it, add the following code to the array inside
' Url_model ' = 2
Look, it's done!
second, use regular routes to modify the delimiter
1, or in the config.php file, the routing function is opened, add the following code
True
2. Use regular route to modify URL last delimiter
Array ( '/([w/]+)/page_ (d+) $/' = ': 1?page=:2 ')
Note that the regular in this case is the same as in PHP, followed by the following: 1 is the PHP regular 1 or the contents of the first parenthesis
This will be configured, now we can test the success! First we print out $_get[' page '], then enter localhost/home/index/index/page_2.html in the Address bar, if the output is 2 then congratulations on your success!
So your localhost/application/common/conf/config.php file needs to be entered with the following code to only change the address URL of a delimiter, I change here is the last delimiter!
return Array ( // set URL mode ' url_model ' = + 2, // start routing function True, // regular route array( / / Modify paging Address '/([w/]+)/page_ (d+) $/' = ': 1?page=:2 ' ) );
This article originates from the personal blog of Wang Ye building. Address: http://www.ly89.cn/detailB/50.html
Welcome to share this article, reprint please indicate the source and address of this article