2

Client wanted to have a trailing slash at the end of urls and it should be redirected with 301. I have configured in IIS Url Rewrite and It is working fine as expected but I am getting an issue in the Analytics Tracker as below

enter image description here

Sitecore version :: 9

Has anyone come across this issue? Kindly give your suggestions

Note: Sitecore experience editor is keep loading after these changes. I have tried installing sitecore rewrite module which breaks the sitecore instance.

  • Can you add your rewrite rule? It is possible to add conditions to it, to avoid redirect of certain URLs. – Anton Apr 2 '18 at 8:06
3

Based on the error above, it looks like you are rewriting too many URL formats. Your client likely wanted folders (like "www.example.com/about-us") rewritten to have trailing slashes, not all file names.

File paths like .htm, .aspx, .css, etc. should not usually be rewritten in this way. It breaks the file extension.

| improve this answer | |
  • Thanks Jay. Is that possible to have rewrite rules only for sitecore pages. I mean content tree along with sub items. As you said, this rule is so generic which is causing the issue. – arjunan Apr 2 '18 at 2:57
  • I don't think that's what your client is trying to do. They are likely trying to enforce canonical usage via rewrite rules so that there are not multiple versions of URLs. I would suggest you clarify what your customer wants to do as a goal so that you can solution properly. – Jason St-Cyr Apr 2 '18 at 12:27
0

Let say you have next rewrite rule:

<rule name="Force trailing slash" stopProcessing="true">
    <match url="(.*[^/])" />
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}/" appendQueryString="true" redirectType="Permanent" />
</rule>

You have to add conditions to avoid redirection of URL that are paths that should not be redirected (paths to files or specific Sitecore paths):

<rule name="Force trailing slash" stopProcessing="true">
    <match url="(.*[^/])" />
    <conditions logicalGrouping="MatchAll">
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
      <add input="{REQUEST_URI}" negate="true" pattern="^.*\.css$" ignoreCase="true" />
      <add input="{REQUEST_URI}" negate="true" pattern="^.*\.aspx$" ignoreCase="true" />
      <add input="{REQUEST_URI}" negate="true" pattern="^.*\.js$" ignoreCase="true" />
      <add input="{REQUEST_URI}" negate="true" pattern="^.*\.ashx$" ignoreCase="true" />
      <add input="{REQUEST_URI}" negate="true" pattern="^sitecore.*\.js$" ignoreCase="true" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}/" appendQueryString="true" redirectType="Permanent" />
</rule>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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