Expanding functionality of redirects

Thanks for the suggestion @niansa!

1 Like

We would love to be able to redirect Internet Explorer users. So User-Agent based redirection would be a great addition to us.

We no longer support Internet Explorer on our platform and are now showing users a page informing them of this fact. Our current redirection is based on a Vue.js route middleware, but even maintaining support for a “we do not support IE” page has proved to be unnecessarily difficult.

howdy @joaobarcia and welcome to our community!

We think that is a bit of an antipattern (see this article for the reasoning: https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent) so we don’t support it now, but if we change our mind and implement it, we’ll post in this thread to let everyone know :slight_smile:

1 Like
  1. Unfortunately, we don’t support negative matches like that. You’ll need a set of content for the language you want, and to make a 404 page for the content you don’t, something like this may work:
  /* /no-content-for-you.html 302! Language=zh
  /* /en 302!
  1. No rules to ignore bots provided on our service. You can set things like robots.txt or an X-Robots-Tag custom HTTP response header to control that

Thanks for the reply and the update :slight_smile:

I’d like to redirect based on the presence of a cookie.

I’m using firebase auth and once a user logs in they have a specific cookie present.

For all users with this cookie present I’d like to redirect them from the root site.com to the subpath where the logged in application is hosted site.com/app. Obviously I can do this client side but it makes for a horrible experience when done like this.

I can’t tell if this is possible using Netlify’s redirect rules.


Yup, client side will be your best bet for “straightforward implementation” at present; we don’t have any functionality like that (yet) but we are working to enable it with some active work.

If you could have a special URL (site.com/amiloggedin) that proxy’d to a function, it could detect the cookie and return conditional redirects, but that isn’t quite as simple as setting up a single redirect.


Interesting idea, I’ll look into that. Also if you wouldn’t mind updating this thread when the active work is completed that would be awesome!


we definitely will, @goleary!


I’m also interested in cookie-based redirects and rewrites (rewrites, in particular). That would help us avoid the implementation of the extra lambda function and keep everything clean with static rendering on Nextjs


yes definitely. We will absolutely post an update here once we have something concrete.

I’d like to +1 the request for supporting conditions based on headers.

My use case:
I’m splitting an existing site into two and would like anything that returns a 404 on the primary URL to redirect to the secondary URL. I can do that in my application but it would be nice if I didn’t have to mess with the routing of my app and had a simple rule in the redirect functionality.


  from = "*"
  to = "http://example.com/:splat"
  status = 301
  conditions = {Headers = { "Status Code": "404" }}
  headers = {X-From = "Netlify"}

I would love to be able to use regular expressions or the like in redirects.

I have a bunch of URLs that originally had underscores in them, but now have dashes instead (something something SEO). Unfortunately, they are still linked to from around the net using the underscore URLs and I would like to redirect them to their proper dasherized versions instead of serving 404 pages.

Something like

from = "\/(.+)_(.+)$"
to = "/$1-$2"

could probably solve my use case, especially if the next request is then processed following the same rule.

Even better would be some way equivalent of modifying the path with Javascript, ie

"/foo_bar_baz".replaceAll(/_/g, "-");

Not sure how that would look in config, perhaps something like

from = "/blog/*"
replace = {pattern = /_/g, with = "-"}

Or perhaps to redirect a daily archive URL (ie /posts/2020/01/20) to the yearly archive:

from = "/posts/*"
replace = {pattern = /(\d+)\/(\d+)\/(\d+)/g, with = "$1"}

Not sure what’s possible im TOML :man_shrugging:

Do you have other wildcard redirects in your primary URL/app? Otherwise, thanks to Netlify’s shadowing behavior, you should be able to just add this redirect:

  from = "*"
  to = "http://example.com/:splat"
  status = 301
  headers = {X-From = "Netlify"}

Any request for a page that exists (e.g., /about.html) will correctly serve the existing page. Any request for a page that doesn’t exist (e.g., /do-not-exist.html) will be forwarded to example.com. But if you have existing wildcard redirects (such as a React Single-Page-Application), this might conflict…

I think the edge handlers will be perfect for this sort of thing: Edge Handlers - Edge Computing Platform — but it’s still in early access.

I guess a workaround for the time being could be to use a Netlify Function to “rewrite” the URL and redirect all unmatched requests for /blog/* to the Netlify Function (/.netlify/functions/rewriteUrl). Happy to share more, if that’d be useful.

Thanks for the tip.

I’ll have to play around with this a bit to see if I can approach it this way.

I want to do Netlify 301 redirect. I don’t want google bot to see 301 redirect. google bot go to the original site. let users go to the redirected site. can i do this?

Hey there, @Ekocem89 :wave:

Apologies, I think I need a bit more information here in order to help you. Can you give an example of your use case here-- what is your netlify site? What would this redirect accomplish? This will help us understand your problem further.

Hey @Ekocem89

You have already opened a thread on this topic

ping @hillary

Oh great catch, @coelmay !!!

@Ekocem89, if you have additional questions, please follow up on the thread you already opened. It looks like you have not been active on the other thread this week.

We want the conversation to stay in one place so that we can streamline our support. Thank you for understanding.

1 Like