Can't get URL Rewrite to work

Discussion in 'DNS/Domain names' started by Robert, Jan 25, 2010.

  1. I still can't figure this out.

    I have as my main website. I want the main website to reside in a subfolder called example.

    so, by default, to get to my site, I have to type

    I want anyone who types in to get redirected to (Action Type: redirect).

    And, I want to show up in the address bar as (Action Type: rewrite).

    I just can't seem to get this figured out, any help would be appreciated.

    -- This is what I have so far --
    My Pattern: example\.com
    Redirect URL: {R:0}/example

    I also have the "append query string" box unchecked.
  2. Ray


    Try setting the redirect URL to R:1 instead of R:0
  3. that won't work, there is no way to get a second backreference.
    Can you even do what I am asking, I've searched around and can't find anybody who has done this. And, surely I'm not the only one.

    This isn't a huge deal, just a matter of preference.
  4. in your pattern, just put instead of example\.com

    then the redirect url should be example\{R:0}
  5. Ray


    First you need to setup the condition rule. Inside the conditions make sure you choose {HTTP_POST} and type the patter ^www.example\.com$

    Then choose Rewrite URL rule and type in the text box \example\{R:1}

    This will look for any http calls to and redirect it to the folder \example but it will keep the URL to show
  6. Thanks for your reply guys.

    The rewrite still didn't work. This is what I have.

    Rewrite URL: \example\{R:0} (I tried {R:1} and it didn't work either)
    - append query string is checked

    {HTTP_POST} Matches the pattern ^www.example\.com$
    - match any

    the webpage loads as normal here.
  7. Ray


    Lets try to make things simple for now. Make the pattern ^example\.com$ and call your site using as a test. I suspect the issue lies in the pattern that IIS is looking for.
  8. Try {HTTP_HOST} instead of {HTTP_POST}.

    Also, it should be {R:1} instead of {R:0}.

                    <rule name="demo" stopProcessing="true">
                        <match url="(.*)" />
                            <add input="{HTTP_HOST}" pattern="^demo\.example\.com$" />
                        <action type="Rewrite" url="/demo/{R:1}" />

Share This Page