my home page and root of my website


I want to install my website in following directory :


So The root of my website (1st lavel) is into "myWebSiteYii2"

The URL of my home page is :

So my home page file is C:\inetpub\wwwroot\[color="#8B0000"]myWebSiteYii2[/color]\index.php

But when I installed Yii2.0, my home page is : C:\inetpub\wwwroot\myWebSiteYii2\[color="#8B0000"]web[/color]\index.php

and The URL of my home page is :[color="#8B0000"]web[/color]/index.php

How I can change this place ([color="#8B0000"]web[/color]/index.php) by removing the name ‘[color="#8B0000"]web[/color]’ in URL ? :rolleyes:

How can I ?

Do you know if the configuration of my installation is wrong ? :mellow:

I tried it like as :

on CMD commande

C:\inetpub\wwwroot\myWebSiteYii2>composer create-project --prefer-dist yiisoft/yii2-app-basic


thanks Tri,

But this doc is for the configuration on Apache or Nginx server.

My web server works on [b]IIS /b.

So how I can change by ?


New UI, not tried. You may set "physical route path" for the site in IIS Manager.

You may want to look at this

  • URL gets mangled, look up "Change the Physical Path of Virtual Directory Content".

We are sorry. The page you requested cannot be found.


in \yii2-app-basic\config here is a php file : web.php

I see this code :

        'db' => require(__DIR__ . '/db.php'),


        'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'rules' => [




So I can use : enablePrettyUrl’ => true

So Do you know if I add /change this file for get instead of change by ?

search for the page about IIS Manager

Something like "Change the Physical Path of Virtual Directory Content"

Or search for a tweaked yii2 basic, something like "yyi2_basic_ext"

Good luck!


I have two solution with web.config file (generated by IIS )

[font="Arial Black"]1st one :[/font]

[xml]<httpRedirect enabled="true" destination="" exactDestination="false" childOnly="true" httpResponseStatus="Found" />[/xml]


[*]When you tape this url : — >

you arrive this url :

[*]but when you write or — >

You see : or

So it is [color="#8B0000"]404[/color] Page not found.

[*]if you tape — >

you can see the contents toto.php file in toto directory.


or you can also try next one

2nd one :

[xml] <rewrite>


			&lt;rule name=&quot;Rewrite Only Root to Virtual Directory&quot; stopProcessing=&quot;true&quot;&gt;

			  &lt;match url=&quot;^/?&#036;&quot; /&gt;


					&lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsFile&quot; negate=&quot;true&quot; /&gt;


			  &lt;action type=&quot;Rewrite&quot; url=&quot;/yii2-app-basic/web/index.php&quot; /&gt;





[*]When you tape this url : — >

you see the same contents ‘Congratulations! page’ (yii2-app-basic/web/index.php/site/index) without change

[*]but when you write or — >

You see the contents index.php or toto.php file in root directory. So You can not see ‘Congratulations! page’ (yii2-app-basic/web/index.php/site/index)

[*]if you tape — >

you can see the contents toto.php file in toto directory.


Bye :)

The purpose of moving the Document Root to a subdir (web) is that files which shouldn’t be accessible from the web, will not be.

Alternative: the user contributed "Yii2 basic ext" rearranged the template so web root will be at top level (original document root)

I think, it is a best solution.

thanks Tri