Need help doing a redirect/rewrite

Hi All,
My team and I are trying to get a couple sites/repos working on Netlify;

Goal

  • Use Site 1 as the main domain authority, while serving other repos/sites within our Netlify account to the necessary subfolders (ie. www.solace.dev/subfolder/)
  • Serve Site 2 under www.solace.dev/codelabs/ while having paths remain working before (locally) and after (deployed to Netlify), so any calls to resources from solace.dev/codelabs/* pages to have their root be solace.dev/codelabs instead of solace.dev

Steps

We first tried using a “_redirect” file, several different ways but this route did not end up working for us, so we moved on to other options and added a netlify.toml file under “Site 1" with the following;

[[redirects]]
  from = "/codelabs/*"
  to = "https://focused-beaver-3cc79d.netlify.com/:splat"
  status = 200
  force = true
  headers = {X-From = "Netlify"}

This serves Site 2 under www.solace.dev/codelabs/, which is what we wanted, but breaks the CSS, images, and scripts (on Site 2), assuming it’s trying to find them from the root folder now, which is now www.solace.dev/*, to confirm making the following changes within the browser fixes the issue;
<script src="/scripts/main.js"></script> to <script src="/codelabs/scripts/main.js"></script>

As a test we then tried to fix broken CSS files by adding a new netlify.toml file under “Site 2” with the following (along with a few other variations of this), all which didn’t work;

[[redirects]]
  from = "/styles/*"
  to = "/codelabs/styles/:splat"
  status = 200
  force = true

We know there has to be a better way to achieve what we want but we’re probably missing something, either by extending our netlify.toml file/files, or perhaps something else we’re not aware of.

We’re in the process of building out more than just Codelabs in the future and would like to ensure we’re setup to grow on Netlify.

The documentation and community threads we had referred to;

Thanks in advance.

1 Like

The suggested workflow for site2 is to deploy under /codelabs (e.g., move your entire site there including /index.html), then things will just work :slight_smile:

The first article you linked does suggest this: [Common Issue] Can I deploy multiple repositories in a single site?

Could you try that out and let me know if it can work for you?