<p>I solved this by creating a <a href="https://github.com/craftcms/redactor#redactor-js-plugins" rel="nofollow noreferrer">Redactor plugin</a> that listens for the <a href="https://imperavi.com/redactor/docs/callbacks/link/" rel="nofollow noreferrer"><code>link.inserted</code></a> event and strips out the site identifer:</p>

<p><code>craft/config/redactor/plugins/myplugin.js</code>:</p>

<pre><code>(function($R)
{
    $R.add('plugin', 'myplugin', {
        onlink: {
            inserted: function(link) { 
                link.nodes.forEach(node =&gt; node.href = node.href.replace(/@\d+/, ''))
             },
        },
    });
})(Redactor);
</code></pre>

<p><code>craft/config/redactor/redactorFieldConfig.json</code>:</p>

<pre><code>{
    "plugins": ["myplugin"]
}
</code></pre>

CC BY-SA 4.0
2020-06-09T23:13:16.570Z
2020-06-09T23:13:16.570Z
Garrett
<p>I have a multi-site setup, and when using Redactor's <strong>Link to an entry</strong> function, by default, site identifiers are added to the link href:</p>

<p><code>href="https://mysite/my-page#entry:4223@3:url"</code></p>

<p>I would like to prevent (or strip out) the <code>@3</code> site identifier, because I wish to use the current site's base URL, rather than specify a specific site's base URL be used. Is this possible?</p>

<redactor><reference-tags>
Prevent Redactor from adding site identifier to entry links
# Prevent Redactor from adding site identifier to entry links

(Asked by: username_0 on 2020-06-09)

I have a multi-site setup, and when using Redactor's **Link to an entry** function, by default, site identifiers are added to the link href:

`href="https://mysite/my-page#entry:4223@3:url"`

I would like to prevent (or strip out) the `@3` site identifier, because I wish to use the current site's base URL, rather than specify a specific site's base URL be used. Is this possible?

**Tags:** redactor, reference-tags


---

## 1 answers

### Answer by username_0 on 2020-06-09. Score: 1 | Accepted answer

I solved this by creating a Redactor plugin that listens for the link.inserted event and strips out the site identifer:
craft/config/redactor/plugins/myplugin.js:
(function($R)
{
    $R.add('plugin', 'myplugin', {
        onlink: {
            inserted: function(link) { 
                link.nodes.forEach(node => node.href = node.href.replace(/@\d+/, ''))
             },
        },
    });
})(Redactor);

craft/config/redactor/redactorFieldConfig.json:
{
    "plugins": ["myplugin"]
}


---

