i was trying to pass ID in URL. I was getting difficulty to do it. So, i was going through tutorials like Larry Ullman - URL Routing.
My problem is: I created confirm.php page and created a controller too but error like NOT FOUND (#404) coming.
SiteController.php
<?php
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\swiftmailer\Mailer;
use app\models\LoginForm;
use app\models\ContactForm;
use app\models\EntryForm;
use app\models\RegisterForm;
use app\models\LoginExecForm;
use app\models\ForgotPasswordForm;
class SiteController extends Controller
{
.
.
public function actionConfirm($id)
{
$id = Yii::$app->request->get('id');
return $this->render('confirm');
}
}
config/web.php
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'urlManager' => [
'showScriptName' => false,
'enablePrettyUrl' => true,
'enableStrictParsing' => false,
'rules' => [
'<controller>/<action:\w+>.<_format>' => '<controller>/<action>',
'v1/<controller>/<action:\w+>.<_format>' => 'v1/<controller>/<action>',
],
],
confirm.php
<?php
/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;
use yii\bootstrap\Modal;
use yii\helpers\Url;
$this->title = 'Register';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-about">
asd
</div>
Error Coming => Not Found(#404)
After i got this error, I added few codes in config/web.php
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'urlManager' => [
'showScriptName' => false,
'enablePrettyUrl' => true,
'rules'=>array(
'<controller:\w+>/<id:\d+>' => '/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '/',
'<controller:\w+>/<action:\w+>' => '/',
),
],
But, now problem is every page is redirecting to index.php page.
What to do ? I'm having No Idea. Please Help me to rectify this problem.