我的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‘=>错了,
http://extractor-frontend.dev/site/about工作得很好..。重写规则是有效的!
发布于 2016-10-09 10:11:38
我为我的yii2应用程序使用下面的代码。我认为您的配置方法符合yii1的条件。建议使用yii2配置方法。
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'myaction/<id>/<param2>' => 'site/myaction',
[
'pattern' => '<action>',
'route' => 'site/<action>',
'defaults' => ['action' => 'index']
],
]
]
https://stackoverflow.com/questions/39942838
复制相似问题