Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IIS Url Rewrite role doesn't work #51

Closed
OlegoO opened this issue Jan 12, 2018 · 1 comment
Closed

IIS Url Rewrite role doesn't work #51

OlegoO opened this issue Jan 12, 2018 · 1 comment
Assignees
Labels

Comments

@OlegoO
Copy link
Contributor

OlegoO commented Jan 12, 2018

Expected behavior

See staging content from robots.staging.tx

Actual behavior

See main robots.txt

Steps to reproduce

  1. Add rule
<rule name="Robots.txt for production domain only" stopProcessing="true">
            <match url="robots.txt" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^(virtocommerce\.com)$" negate="true"/>
            </conditions>
            <action type="Rewrite" url="/robots.staging.txt" />
        </rule>
  1. Open https://vc-public-qc.azurewebsites.net/robots.txt
  2. Should see content from robots.staging.txt
@OlegoO OlegoO added the bug label Jan 12, 2018
@OlegoO OlegoO added this to the Operations milestone Jan 12, 2018
@tatarincev tatarincev self-assigned this Jan 12, 2018
@tatarincev
Copy link
Contributor

This rule doesn't work because ASP.NET Static files middleware handle exists files first rather than UrlRewrite due to the registration order in Startup.cs

...
  app.UseStaticFiles();
...
 app.UseRewriter(rewriteOptions);

So my suggestion to define two production-robots.txt and staging-robots.txt files and add to IISUrlRewrite.xml next rules

 <rule name="Robots.txt prod" stopProcessing="true">
            <match url="robots.txt" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^(virtocommerce\.com)$" negate="true"/>
            </conditions>
            <action type="Rewrite" url="/staging-robots.txt" />
        </rule>
        <rule name="Robots.txt staging" stopProcessing="true">
            <match url="robots.txt" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^(virtocommerce\.com)$"/>
            </conditions>
            <action type="Rewrite" url="/production-robots.txt" />
        </rule>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants