# URL Rewriting

The reason we implemented **Global Rewriting** vs **Selective Rewriting** is because of the nature of [Microsite functionality](/domainmappingsystem-docs/features/creating-microsites-multisite-alternative.md) and the importance of Internal Links.&#x20;

When mapping domains, you need to be careful about Internal Links. If you're linking to a page that is not mapped properly, the link will be considered a "dead link" and your website visitor may arrive to a 404 or different page than intended.&#x20;

Because many links are automatically generated in WordPress (like menu bar, copyright bar in some themes, etc), we created the URL Rewriting mechanism to properly allow internal linking.&#x20;

### Global URL Rewriting

If you're building a subsite and don't want anyone to visit any other URLs on your site, Global Rewriting is beneficial because it forces all URLs on that page to go to the mapped domain the visitor sees in their browser window.&#x20;

{% hint style="danger" %}
Warning: When using Global URL Rewriting, ensure you've mapped all the pages that are "linked to" on your mapped pages. If you don't, you'll have dead links that go to 404 because they are not mapped and the URL has been rewritten to the mapped version of any linked page.&#x20;
{% endhint %}

The main benefit of Global Rewriting will prevent this visitor from seeing any other domain when navigating your site.&#x20;

With Global Rewriting enabled, the URL your visitor sees in their browser's URL bar will match all the links on the page they're viewing, excluding any external links.&#x20;

#### What URLs are rewritten?&#x20;

* All of them, including:
  * Hardcoded links.
  * Any automatically generated links that have WordPress hooks (logo URL, menu items, footer copyright content, etc).  &#x20;

### Selective URL Rewriting

If you're mapping domains and don't have a strong preference about whether or not internal links will allow visitors to navigate to other domains mapped to your site, then you'll want to leave Selective URL Rewriting enabled.

The benefit of Selective Rewriting is that mapped pages are automatically detected before a link is rewritten.

For example, if you have a menu bar with 10 items and 5 of them have unique mapped domains attached, those menu item URLs will be rewritten to their corresponding mapped URLs.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://domainmappingsystem.gitbook.io/domainmappingsystem-docs/features/url-rewriting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
