Forward a subdomain to an external site

My hosting is set up with Netlify (domain registered with Namecheap), and I’ve set up a new site for a subdomain that I want to use purely as a redirect to an external site (Webflow URL).

Main domain is - studiotache.co
Subdomain is - Wholesale.studiotache.co
External URL - studio-tache-wholesale.webflow.io

My _redirect file is - /* https://wholesale.studiotache.co/:splat 301! /* https://studio-tache-wholesale.webflow.io/:splat 301!
I’ve done a heap of variations of this with having /page, no :splat, etc this is just where I’m at, and can’t see what’s going wrong as all should work.

When I upload my deploy log says No redirect rules processed even though I’m uploading a plain text doc with no .txt extension (it does add the .txt when it uploads to Netlify, so maybe that’s the issue?)

All suggestions welcome and will be tried, I’m just out of moves to make this work.

@Zendall If you check the documentation here:

You’ll see that the file should be called _redirects (not _redirect)

I also don’t believe there’s anything in Netlify’s handling that would “add a .txt extension” to the file.

Are you working on an operating system that hides file extensions?

If you’re on Windows for example you could follow this tutorial:

1 Like

Hey @nathanmartin - So I can confirm my file is actually called “_redirects” and I forgot the S whilst writing this, I’m sorry about that!

You were on the money with the hidden extension, my Mac was hiding the extensions, so have removed that and 1 redirect rule processed, so we have the connection (BIG YAY). The URL doesn’t forward though.

Any further thoughts on what might be wrong with the text I’ve input in there?

(Thanks for linking that article on redirects and rewrites, I’ve been up and down that page the prior 2 hours while doing this and trying to work it out with the netlify Ai to no avail)

@Zendall What’s the current contents of your _redirects file?

You can copy and paste it onto the forum here, and put it inside a Markdown code block by using ``` before and after.

/* https://wholesale.studiotache.co/:splat 301! /* https://studio-tache-wholesale.webflow.io/:splat 301!

@nathanmartin

@Zendall If the contents are exactly as you’ve specified then I’d imagine there are a few things wrong.

The first one would be that you’ve specified two rules, but it’s all on one line.

It should be:

/* https://wholesale.studiotache.co/:splat 301!
/* https://studio-tache-wholesale.webflow.io/:splat 301!

Even then, the rules as specified wouldn’t make much sense though, as they both “catch all” but redirect to two different locations, since they process top down only the first one would ever occur.

Do you have two site instances set up in Netlify, one for the main site at studiotache.co and one for wholesale.studiotache.co?

If you do, then for the wholesale.studiotache.co site you probably just want a _redirects with:

/* https://studio-tache-wholesale.webflow.io/:splat 301

You shouldn’t need to use the ! for force unless you’re also uploading html files along with the _redirects and want it to redirect even when it would otherwise show those files.

Note that since you’ve specified 301 it won’t be serving that webflow site as if it’s at wholesale.studiotache.co, it would literally redirect the users browser to studio-tache-wholesale.webflow.io.

If you’re trying to serve it as if it’s actually at wholesale.studiotache.co then you could try a proxy

@nathanmartin - Ahh okay, so yes, I did have them on one line, my understanding was that you first specify the trigger (user visits wholesale.studiotache.co) and then specify the action that takes place (redirects them to the Webflow site).

I’ve tried both mentioned snippets and still no redirect, but I did only put the _redirects file mentioned on the subdomain, not the main site, do I need to add it to the main site for it to validate the domain?

The 301 is currently ideal due to my prior thoughts that this would be straightforward and fast, as this is just an MVP, and not concerned about the minimal people that may notice the redirect. The proxy would be ideal, but looking at how horribly I’ve gone with this, I’m avoiding that at this stage.

I am having a play around with your static.tools, look interesting and a better solution to Snipcart as I’m using now for commerce on my static sites.

@Zendall You won’t need to put any redirects on the main site instance.

You would only the need _redirects file on the subdomain instance, and it should just effectively be saying “push all requests for any route to {destination}”.

There’s little difference between the redirect and the proxy, it’s just the status code, if you were planning on testing it out you could start just by specifying 302 instead of 301, just so that your own browser treats it as temporary and it doesn’t “get stuck”.

We were originally users of Snipcart and built our solution to overcome various limitations and provide features that were either too limited or missing entirely. It’s unfortunately not super intuitive to work with though as we’ve kept iterating and are nearing the release of new systems under a rebrand.

1 Like

@nathanmartin - Hmm curious as I’ve input exactly that in the _redirects folder and the only other thing I uploaded with it is a blank index.html file, yet it doesn’t work.

If I’ve signed up, will you be emailing everyone when the rebrand launches or how’s best to stay up to date on that as I’m super interested in using it.

That’s not that curious, as per this comment:

Without force it will serve any files that do exist.
In this case the index.html file which is served as the root, but I’d expect it to redirect for all other routes.

So you would either remove the index.html file, or adjust the rule to 301!

Regarding static.tools, it may be impossible to get going without our assistance currently, but we’re easily contactable by email/chat, and the details are on the site.

1 Like

@nathanmartin, you’ve taught me a lot and this now works which I honestly didn’t see happening. Truly I can’t thank you enough for spending a good chunk of your Tuesday evening helping break this down for a complete stranger.

I’ll be sure to reach out to you or someone on the team tomorrow about this, as it’s super intriguing.

Again, thank you so damn much for all this!

@Zendall It’s no problem at all, glad I could get you sorted out!

1 Like