Skip to content

Instantly share code, notes, and snippets.

@anthony-curtis
Last active June 15, 2017 01:56
Show Gist options
  • Save anthony-curtis/8dffd415b3cdfd881fbc6508d969ebee to your computer and use it in GitHub Desktop.
Save anthony-curtis/8dffd415b3cdfd881fbc6508d969ebee to your computer and use it in GitHub Desktop.
How to Configure localtest.me subdomain with IIS Express

How to Configure localtest.me subdomain with IIS Express

Want to host a local dev site from a custom subdomain using the localtest.me approach? Follow these steps on your Windows machine to get up and running.

  1. Locate your ApplicationHost.config file in \Users\YourName\Documents\IISExpress\config

  2. Make a copy in case you need to revert changes

  3. Open the file in your favorite text editor and scroll to <sites> which will be around line 155.

  4. Add a new <site> element below the default example. Use the code below as a template:

    <!-- Change "NewSite" to a name that suits your project -->
    <site name="NewSite" id="2" serverAutoStart="true">
        <application path="/">
            <!-- Change path to point to your web files -->
            <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\path-to-build-folder" />
        </application>
        <bindings>
            <!-- Change subdomain and port -->
            <binding protocol="http" bindingInformation="*:80:custom-subdomain.localtest.me" />
        </bindings>
    </site>
  5. Open a command prompt with administrative privileges and create a new url reservation:

    netsh http add urlacl url=http://custom-subdomain.localtest.me:80/ user=YourName
  6. Navigate to the IIS Express folder (usually under C:\Program Files (x86)\IIS Express) and open a command prompt. Pro tip: Press SHIFT+F10, then W, then ENTER to quickly open a command prompt from any folder.

  7. Start IIS Express for your new site using the following command from the IIS Express folder:

    iisexpress /site:NewSite
  8. Navigate to your url and test.

Notes:

%IIS_SITES_HOME% will likely point to \Users\YourName\Documents\My Web Sites

Credits:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment