Thinkphp access question: how does thinkphp implement strings of different lengths after the domain name and access different controller methods?
For example:
Coding1 is a string consisting of five letters and digits.
Coding2 is a string consisting of 6 letters and digits.
How to implement demo. me/coding1 to access method A in controller
Demo. me/coding2: Method B in the B controller
Reply to discussion (solution)
There are many methods. You can first enter A method test through the entrance to judge the coding degree in test and choose to enter a/a or B/. You can also use htaccess reWrite. I suggest using htaccess.
Can you tell me in detail how to use htaccess?
In htaccess, write it like this.
RewriteEngine on
RewriteCond % {REQUEST_FILENAME }! -D
RewriteCond % {REQUEST_FILENAME }! -F
RewriteRule ^ ([a-zA-Z0-9] {5}) $ index. php/A/$1 [QSA, PT, L]
RewriteRule ^ ([a-zA-Z0-9] {6}) $ index. php/B/B/$1 [QSA, PT, L]
RewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L]
ErrorDocument 403/404 .html
ErrorDocument 404/404 .html
404 page, you can do it yourself
It seems that it has not taken effect. htaccess
View the apache configuration file
Check whether this line of AllowOverride None exists.
If yes, change None to All. restart apache.
Thank you.