Restrict Your Site to a Custom Domain Only

To ensure that visitors only access your site through your custom domain and not through default subdomains (-bullet.pages.dev or .bullet.site), add a JavaScript redirect to your site. This simple script will check the current domain and redirect users to the custom domain if they’re on a bullet site.

Add the Redirect Script

Paste this JavaScript code into the Code > Body section. Replace yourcustomdomain.com with your actual custom domain.

javascript
`<script>`

  (function() {

    const currentHost = window.location.hostname;

    // Specify your custom domain here

    const customDomain = "yourcustomdomain.com";

    // Check if the current host includes "-bullet.pages.dev" or ".bullet.site"

    if (currentHost.includes("-bullet.pages.dev") || currentHost.includes(".bullet.site")) {

      // Redirect to the custom domain while preserving the path and query parameters

      const newUrl = window.location.href.replace(currentHost, customDomain);

      window.location.replace(newUrl);

    }

  })();

`</script>`

For sub-directory sites

However if you are on a sub-directory sites, you can simply replace “yourcustomdomain.com” with something like “yourcustomdomain.com/blog”. It would work seamlessly.