我的 yii2 rest 可以很好地处理这个请求 http://extractor-frontend.dev/property?id=JP000004 我会处理这个 http://extractor-frontend.dev/property/JP000004
这是我在 config/web.php 中的 urlManager
urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
[
'class'=>'yii\rest\UrlRule',
'pluralize' => false,
'controller' => 'property',
'tokens' => [
'{id}' => '<id:\\w+>'
],
'extraPatterns' => ['GET,HEAD property/{id}' => 'index',]
]
],
],
这是我在网络上的 .htaccess
RewriteEngine on
Options Indexes
Require all granted
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
如果把'enableStrictParsing' => false,
http://extractor-frontend.dev/site/about 工作正常......重写规则工作!