hdzillar
hdzillar

Reputation: 77

Adding a forward slash when typing the URL for Umbraco site

I have a website using the Umbraco CMS. When clicking links on the website the url will appear with the forward slash at the end. e.g. www.mysite.com/home/

Although if I type out the URL it will show www.mysite.com/home

The forward slash becomes missing.

There is a URL rewrite config but I am not sure if a config needs to be created there or in the web config.

I found something similar to my situation on this website but the solution is for the opposite, to remove the forward slash

Has anyone come across this issue or knows a solution?

Thank you.

Upvotes: 1

Views: 732

Answers (1)

Davor Zlotrg
Davor Zlotrg

Reputation: 6050

I am using web.config to do that.

<system.webServer>
    ...
    <rewrite>
      <rules>

        <rule name="Add trailing slash" stopProcessing="true">
          <match url="(.*[^/{2,}])$" ignoreCase="true" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/umbraco/" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/install/" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/([0-9]+).aspx" negate="true" />
            <add input="{URL}" pattern="^.*\.(asp|aspx|axd|asmx|css|js|jpg|jpeg|png|gif|mp3|htm)$" negate="true" ignoreCase="true" />
            <add input="{URL}" pattern="/Base" negate="true" />
            <add input="{URL}" pattern="cdv=1" negate="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
        </rule>

      </rules>
    </rewrite>
    ...
</system.webServer>

Upvotes: 3

Related Questions