separator problem
太子
太子 2018-10-09 10:40:03
0
3
1470

Hello teacher, the address demonstrated in your videowww.tp5.com/hello/aaa/dddd-33-ccc-444-eee-5555.html is displayed like this, but after modifying the configuration file separator The displayed address is not the address of your color but www.tp5.com/hello-aaa-dddd-33-ccc-444-eee-5555.html. When clicking, it prompts that the hello module is not found.

What is the reason?

太子
太子

reply all(3)
包子จุ๊บ

Moderator, have you found a solution? I also encountered this problem. I changed the separator and then output it in the URL address bar saying: Template not found. How to solve this problem?

Peter-Zhu

Your question and answer involves combination variable rules in routing:

Route::get('item-<name>-<id>', 'product/detail')
    ->pattern(['name' => '\w+', 'id' => '\d+']);

The advantage of combined variables is that there are no fixed separators in routing rules, and you can combine the required variable rules and separators at will, for example Routing rules can be supported by changing them to the following:

Route::get('item<name><id>', 'product/detail')
    ->pattern(['name' => '[a-zA-Z]+', 'id' => '\d+']);Route::get('item@<name>-<id>', 'product/detail')
    ->pattern(['name' => '\w+', 'id' => '\d+']);

The above official website describes the variable rules. If you have many variables, in order to generate a URL address that is friendly to search engines, you can use combined variable rules to beautify you. URL address, but it will lose a certain execution efficiency. If your operation has no parameters or default parameters, you should pay attention to the changes in the rules to prevent failure~~

秋香姐家的小书童

Routing rules or pseudo-static rules are not configured.

  • reply 'pathinfo_depr' => '-', setting this will display www.tp5.com/hello-dddd-33-ccc-444-eee-5555.html. Such a connection routing rule also rewrites 'hello/[ :dddd]/[;ccc]/[:eee]' =&gt; ['index/index/hello', ['method' =&gt; 'get'], ['dddd' =&gt; '\d{4 }','ccc' =&gt; '\d{4}'.'eee' =&gt; '\d{4}']], Did I write the rules wrong?
    太子 author 2018-10-09 11:41:28
  • reply Can you give me some guidance?
    太子 author 2018-10-09 11:41:43
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!