---
title: "Configure URL rewriting"
slug: "configure-url-rewriting"
abstract: "Customize URL rewriting when integrating a rendering host with Sitecore editors."
---
# Configure URL rewriting

To ensure that relative links in HTML are rendered properly when integrating a rendering host with advanced Sitecore editors, Headless Services rewrites relative URLs in the returned markup to be absolute. The default tags and attributes included in this processing are as follows:

| Tag name | Attribute name |
| --- | --- |
| `audio` | `src` |
| `img` | `src`, `srcset` |
| `link` | `href` |
| `script` | `src` |
| `source` | `src`, `srcset` |
| `track` | `src` |
| `video` | `poster`, `src` |

## Disable URL Rewriting

If you do not want Headless Services to rewrite relative URLs in the returned markup into absolute URLs, you can disable URL rewriting.

To disable URL rewriting:

- In your app configuration, for the configured `http` render engine instance, change the value of the option`EnableRelativeLinkProcessing` to `false`:

    ```xml
    <javaScriptServices>
      <renderEngines>
        <renderEngine name="http">
          <instance id="RenderEngineInstance" inherits="defaults">
            <EnableRelativeLinkProcessing>false</EnableRelativeLinkProcessing>
          </instance>
        </renderEngine>
      </renderEngines>
    </javaScriptServices>
    ```

## Configure rewritten HTML attributes

You can customize URL rewrites by modifying the configuration for the rendering engine instance.

To configure rewritten HTML attributes:

- In your app configuration, for your configured `http`rendering engine instance, in a `LinkReplacement` element, specify the attributes used for link replacement using `LinkMap` elements. For example:

    ```xml
    <javaScriptServices>
      <renderEngines>
        <renderEngine name="http">
          <instance id="RenderEngineInstance" inherits="defaults">
            <LinkReplacement>
              <LinkMap tag="audio" attributes="src" />
              <LinkMap tag="img" attributes="src, srcset" />
              <LinkMap tag="link" attributes="href" />
              <LinkMap tag="script" attributes="src" />
              <LinkMap tag="source" attributes="src, srcset" />
              <LinkMap tag="track" attributes="src" />
              <LinkMap tag="video" attributes="src, poster" />
            </LinkReplacement>
          </instance>
        </renderEngine>
      </renderEngines>
    </javaScriptServices>
    ```

## Add a path to ignored paths

Some relative URL paths must not be rewritten by Headless Services. By default, these are:

- `-/media/`
- `~/media/`
- `-/jssmedia/`
- `~/jssmedia/`

To add a URL path to the ignored paths:

- In your app configuration, for your configured `http`rendering engine instance, specify the ignored paths in an `IgnoredPaths` element using`Path` elements. For example:

    ```xml
    <javaScriptServices>
      <renderEngines>
        <renderEngine name="http">
          <instance id="RenderEngineInstance" inherits="defaults">
            <IgnoredPaths>
              <Path>-/media/</Path>
              <Path>~/media/</Path>
              <Path>-/jssmedia/</Path>
              <Path>~/jssmedia/</Path>
              <Path>sitecore/shell/</Path>
            </IgnoredPaths>
          </instance>
        </renderEngine>
      </renderEngines>
    </javaScriptServices>
    ```