0

I am trying to remove the web folder in the URL of my Yii2 web application hosted on windows server. I want my application to be accessed at http://example.com instead of http://example.com/web I have managed to enable pretty URLs using the code below.

    <rules>
            <rule name="Imported Rule 1" 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" />
            </rule>
        </rules>

how do I achieve this?

KMarto
  • 300
  • 2
  • 23
  • Create a website in IIS and set up the physical path pointing to the Web folder (path/to/app/web), and then place your webconfig file with your above content. – Abraham Qian Jun 08 '20 at 09:36

3 Answers3

1

These instructions are not for IIS but for Apache, you configure the Document root to the web folder.

https://www.yiiframework.com/doc/guide/2.0/en/start-installation#recommended-apache-configuration

Or maybe this answer will help guide you in the right direction.

IIS document root in subfolder

Craig London
  • 675
  • 1
  • 9
  • 14
1

The simplest and direct solution for your requirement is to follow exactly the regarded IIS configuration in the official documentation.

In other words, you have to create a virtual host (it may be called Sites in IIS) on your that points to the web directory of your project and place web.config file with the code regarded in the documentation there.

Hint: you may need to edit your Windows hosts file to allow accessing this host locally.

SaidbakR
  • 13,303
  • 20
  • 101
  • 195
0

It's actually very easy on IIS when using Plesk. Just change the document root to include the web folder.

change the document root and include the web folder

KMarto
  • 300
  • 2
  • 23