thinkphp3.2.3 How to change only one delimiter in the address URL, the other remains the same

Source: Internet
Author: User
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

  • 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.