yii-url-manager

Yii check if homepage

自闭症网瘾萝莉.ら 提交于 2019-12-05 07:43:17
Is there a buildin method or property in Yii to check if page is homepage? I know i can use something like this: $controller = Yii::app()->getController(); $isHome = $controller->getAction()->getId() === 'index' ? true : false; Or put it in a method in main controller, but i am looking for something cleaner. Thanks. Rajat Singhal If You want to check the current page, ie action is the default of the current controller.. $controller = Yii::app()->getController(); $isHome = $controller->action->id === $controller->defaultAction->id ? true : false; dafeultaction may not always be 'index', it can

how to remove url (/web/index.php) yii 2 and set route with parameter with clean url?

六眼飞鱼酱① 提交于 2019-11-30 08:50:46
问题 first question: i already remove index.php , but i want remove /web also. this is my .htaccess 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 and this is config/web.php 'urlManager' => [ 'class' => 'yii\web\UrlManager', // Disable index.php 'showScriptName' => false, // Disable r= routes 'enablePrettyUrl' => true, 'rules' => array( '

how to remove url (/web/index.php) yii 2 and set route with parameter with clean url?

99封情书 提交于 2019-11-29 07:49:54
first question: i already remove index.php , but i want remove /web also. this is my .htaccess 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 and this is config/web.php 'urlManager' => [ 'class' => 'yii\web\UrlManager', // Disable index.php 'showScriptName' => false, // Disable r= routes 'enablePrettyUrl' => true, 'rules' => array( '<controller:\w+>/<id:\d+>' => '<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/

Enable clean URL in Yii2

别等时光非礼了梦想. 提交于 2019-11-26 21:35:28
How can I enable clean urls in Yii2. I want to remove index.php and '?' from url parameters. Which section needs to be edited in Yii2 for that? user7282 I got it working in yii2. Enable mod_rewrite for Apache . For basic template do the following: Create a .htaccess file in web folder and add this 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 Then inside config folder, in web.php add to components 'urlManager' => [ 'class' => 'yii\web

Enable clean URL in Yii2

[亡魂溺海] 提交于 2019-11-26 07:22:54
问题 How can I enable clean urls in Yii2. I want to remove index.php and \'?\' from url parameters. Which section needs to be edited in Yii2 for that? 回答1: I got it working in yii2. Enable mod_rewrite for Apache . For basic template do the following: Create a .htaccess file in web folder and add this 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