0

I have updated a redirection rule for my site,

<rule name="main mysitecom redirect" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<conditions>
  <add input="{HTTP_HOST}" pattern="^(?:(www|local))?(.mysite\.com)$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/en" appendQueryString="false" />

This rule will redirect the page to default language "en" when user types the url on browser. Sitecore login -> Experience editor through this url is not working. When I try to open any item in experience editor while accessing through the given url in browser, it is redirecting to home page directly.

How can I fix this issue ?

1
  • 1
    Try adding <add input="{QUERY_STRING}" pattern="^$" /> to <conditions> to make sure your rule is only executed when there is no query string
    – Marek Musielak
    Commented Feb 12, 2019 at 10:34

2 Answers 2

1

This can be achieved by updating the following line to <conditions> in Rewrite rules

<add input="{HTTP_URL}" pattern="\?.*sc_mode" negate="true" />
1

Add condition

<add input="{QUERY_STRING}" pattern="^$" />

to <conditions> of your rule:

<rule name="main mysitecom redirect" stopProcessing="true">
    <match url="^$" ignoreCase="false" />
    <conditions>
      <add input="{HTTP_HOST}" pattern="^(?:(www|local))?(.mysite\.com)$" />
      <add input="{QUERY_STRING}" pattern="^$" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/en" appendQueryString="false" />
</rule>

This will make sure your redirect is only executed when url doesn't have query string which is the case for Experience Editor which uses sc_mode parameter.

You should not exclude sc_mode parameter only, as there may be other meaningful query strings which you don't want redirect (e.g. sc_camp for campaign id which will never be triggered if you check sc_mode parameter only).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.