Pretty urls with redirect to another instance


I’m trying to redirect an url from an existing instance lacunae to another instance lavouivre: →

In _redirects of lacunae, I added this rule:

/others/la-vouivre/*  200

And it is working with (trailing slash) will found
but web-app.js will not load as the url will be and not

In lacunae, I also have that rule that may interfer with Pretty urls

from = "/*"
to = "/index.html"
status = 200
force = false
headers = { X-From = "Netlify" }

Or I guess Pretty urls don’t see as a folder and don’t add the trailing slash.

Is there a solution to add a trailing slash to and redirect to ?

You would either need to make sure the resources are in the same place on both sites or set up a redirect so that it looks for the correct place in the site.


Thanks for your response.

I’m not sure I can do the first option since it is two different project.
And I would be better to not redeploy lacunae with lavouivre changes.

set up a redirect so that it looks for the correct place in the site.

How would do suggest to do that?
Via the _redirects file?

I would be nice if could redirect to

@sagix Stepping through what you have…

The reference to web-app.js is defined as ./web-app.js in the HTML

When the page is loaded via:

./web-app.js resolves to:

The _redirects targeting /others/la-vouivre/* cause that to resolve to:

The file does exist there.

When the page is loaded via:

./web-app.js resolves to:

This isn’t targeted by _redirects, and doesn’t exist.
A catch-all redirect appears to be returning the contents of your index.html

I understand this may not be precisely what you’re currently requesting, but there are several ways you could account for what’s happening:

  1. By changing the reference for web-app.js to an absolute URL that would work anywhere, e.g.

  2. By adding a proxy so /others/web-app.js resolves correctly

    /others/web-app.js  200
  3. You could try a redirect exactly like you’ve suggested (but I’m unsure if it would work)

    /others/la-vouivre  /others/la-vouivre/  301

Hi Nathan,

Thanks for your help.
I don’t want to go into 1 or 2, because it means that I would have to do that for all resources (I plan to had images too)

I tried 3, but it is not intended to work:

# This rule will cause an infinite redirect
# because the paths are effectively the same
/blog/remove-my-slashes/   /blog/remove-my-slashes  301!

For now the workaround I found is to do a redirection via a html script in lavouivre index.html

    if (window.location.pathname.slice(-1) !== '/') {
            window.location.href.replace(window.location.pathname, window.location.pathname + '/')

Not pretty but it is working :sweat_smile:

1 Like

Hi @sagix :wave:t6: glad to hear it!

@sagix Nice workaround.

As I understand it, the trailing slash is supposed to operate as outlined here: