I am having a very weird problem with routes under IIS. My server is located under D:\webroot\volunteers and the structure is in the following way:
- volunteers
– components
– controllers
— HomeController
— AdminController
– extensions
– runtime
– lib
— yii
– config
— config-main.php
–public
— index.php
And here is the config-main:
return array(
'basePath'=>ROOT,
'runtimePath'=> realpath(ROOT.'/runtime'),
'import'=>array(
'root.controllers.*',
'root.components.*',
'root.models.*'
),
'components'=>
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
'rules' => array(
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
)
)
),
/* .... */
);
the index.php
define('ROOT', dirname(__DIR__));
require_once (realpath(ROOT.'/lib/yii/yii.php'));
$config = include(realpath(ROOT.'/config/config-main.php')),
Yii::setPathOfAlias('root', ROOT);
Yii::createWebApplication($config)->run();
and the web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="hide-index-php-yii" stopProcessing="true">
<match url="." ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The problem:
When I am in a controller (lets say ‘admin’ but it applies to all), Yii::app()->controller->createUrl(‘view’,array(‘id’=>1)) should create ‘/admin/view/id/1’, but it creates url ‘/volunteers/public/admin/view/id/1’. I never had a problem like that on a linux system but at work I have no choice other than using IIS7. What can I do to fix this?
- Gasim