Thinkphp supports case-sensitive URL address access without underlining

Source: Internet
Author: User

From:http://www.111cn.net/phper/thinkphp/57748.htm

First, in the configuration file opened the Thinkphp case recognition feature, so that the link case can be accessed normally:

' Url_case_insensitive ' =>true

The file name is canonical, but the URL is not properly obtained when using __url__ in the template to get the current URL path.

This is written in the manual:

There is a place to note that if we define a Usertypeaction module class, then the URL should be accessed:

Http://serverName/index.php/user_type/list

Instead of

Http://serverName/index.php/usertype/list

The link to use __url__ in the template is the one below, not underlined.

Second, the solution is to modify the source of TP:

In the Dispatcher.class.php file under the core folder of the Lib folder of TP, find 181 rows, here define the __url__ address to get the way:

Code to copy code as follows
$moduleName = defined (' Module_alias ')? Module_alias:module_name;
if (define (www.111cn.net) d (' group_name ')) {
Define (' __url__ ',!empty ($domainModule)? __group__. $depr: __group__. $depr. ( C (' url_case_insensitive ')? Strtolower ($moduleName): $moduleName));
}else{
Define (' __url__ ',!empty ($domainModule)? __app__. ' /': __app__. ' /‘. (C (' url_case_insensitive ')? Strtolower ($moduleName): $moduleName));
}

Put one of the C (' url_case_insensitive ')? Strtolower ($moduleName): $moduleName) changed to:

Code to copy code as follows
C (' url_case_insensitive ')? Parse_name ($moduleName, 0): $moduleName

That's OK!

Thinkphp supports case-sensitive URL address access without underlining

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.