IIS Rewrite Not Working As Expected

Discussion in 'Site Programming, Development and Design' started by Austin Collins, Jun 9, 2015.

  1. I have a folder here (http://etreecycle.co.uk/__austincollins/) and I have successfuly used the subdomain to austin.etreecycle.co.uk to access it. As you can see it displays the index file in the folder, however to view any other content it needs the folder name as a directory.

    For example; There is a folder called /dev/ within /__austincollins/. (/__austincollins/dev/)
    To view this folder I would like to go to austin.etreecycle.co.uk/dev/ but the current setup means I have to go to austin.etreecycle.co.uk/__austincollins/dev/. I can't see what is causing this from the current setup.

    This is the web.config file:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <staticContent>
          <remove fileExtension=".svg"/>
          <mimeMap fileExtension=".svg" mimeType="image/svg+xml"/>
        </staticContent>
        <rewrite>
          <rules>
                <rule name="wordpress" patternSyntax="Wildcard">
                    <match url="*"/>
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                        </conditions>
                    <action type="Rewrite" url="index.php"/>
                </rule>
                <rule name="__austincollins" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(austin.)etreecycle.co.uk" />
                    <add input="{PATH_INFO}" pattern="^/__austincollins/" negate="true" />
                </conditions>
                <action type="Rewrite" url="\__austincollins\{R:1}" />
            </rule>
            </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    The section I am focusing on is the __austincollins rule.
    Code:
    <rule name="__austincollins" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(austin.)etreecycle.co.uk" />
                    <add input="{PATH_INFO}" pattern="^/__austincollins/" negate="true" />
                </conditions>
                <action type="Rewrite" url="\__austincollins\{R:1}" />
            </rule>
    

    How can I avoid the extra folder directory being displayed in the URL?

    Thank you.
     
  2. FredC

    FredC Winhost Staff

    won't this work?

    <action type="Rewrite" url="\{R:1}" />
     
    Elshadriel and Michael like this.
  3. That gives the same result, however you can then access the root files from the subdomain.

    What I don't understand is why austin.etreecycle.co.uk shows the file /__austincollins/ but to view /__austincollins/example.html you need to go to austin.etreecycle.co.uk/__austincollins/example.html shouldn't it just be austin.etreecycle.co.uk/example.html?
     
  4. Did you find an answer to this? Been grappling with rewrites and redirects for the last couple days. Still haven't got it right
     
  5. Elshadriel

    Elshadriel Winhost Staff

    This is the rewrite rule I use:
    Code:
    <rewrite>
      <rules>
        <rule name="Rewrite to secondarydomain" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^www.secondarydomain.com$" />
          </conditions>
          <action type="Rewrite" url="subfolder_name/{R:1}" />
        </rule>
      </rules>
    </rewrite>
    
     
  6. @Elshadriel please see http://forum.winhost.com/threads/ii...ne-time-only-ssl-error-browser-caching.17859/ for my specific problem. Thje subfolder rewrite is not the problem
     

Share This Page