アプリケーションでカスタム URL を使用しました。メッセージを作成すると作成フォームにリダイレクトされますが、フォームを送信すると同じフォームに再度リダイレクトされます。$_POST 変数が設定されている場合はコントローラーに条件があり、保存しない場合はフォームにリダイレクトされます。$_POST 変数が設定されていないと思いましたが、フォームに印刷するとそこに印刷されました。では、$_POST 変数が設定されている場合、なぜ条件が失敗するのでしょうか? 以下は私のカスタムURLです。カスタム URL を使用する前は、問題なく動作していました。
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'' => 'questions/index',
'messages' => 'messages/index',
'tags' => 'tags/index',
'login' => 'site/login',
'signup' => 'users/create',
'<id:\w+>' => 'users/view',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'gii' => 'gii',
'gii/<controller:\w+>' => 'gii/<controller>',
'gii/<controller:\w+>/<action:\w+>' => 'gii/<controller>/<action>',
),
),
これが私の .htaccess ファイルです。
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>
ここで何か問題がありますか..?
編集
これが私のコントローラーコードです。
public function actionUpdate($id) {
$model = $this->loadModel($id);
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
if ($model->save())
$this->redirect(array('view', 'id' => $model->id));
}
$this->render('update_info', array(
'model' => $model,
));
}