Can ELB redirect request depending on the URL?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Whether ELB can redirect based on the URL depends on which Elastic Load Balancer type you mean. Classic Load Balancer cannot do this in a meaningful application-layer way, but Application Load Balancer can inspect HTTP requests and either route or redirect them based on host and path rules.
Know Which Load Balancer You Are Using
The term "ELB" is often used loosely, but AWS has multiple load balancer types with different capabilities.
- Classic Load Balancer is older and limited
- Network Load Balancer works at Layer 4 and is not a URL-aware redirect engine
- Application Load Balancer works at Layer 7 and understands HTTP host and path conditions
If the requirement is "redirect /old-path to /new-path" or "send /api somewhere else," you are usually talking about Application Load Balancer.
Redirect Versus Forward Are Different Actions
Application Load Balancer listener rules can do more than one thing. Two common actions are:
- '
forward, which sends the request to a target group' - '
redirect, which returns an HTTP redirect response to the client'
That distinction matters.
If you want /images/* to be served by one service and /api/* by another, that is routing with forward actions.
If you want the client browser to receive a 301 or 302 and make a new request to another URL, that is a redirect action.
Example: Path-Based Redirect With ALB
Conceptually, the rule is:
- if path matches
/old/* - send a redirect response to
/new/...
An example AWS CLI rule looks like this:
That tells ALB to inspect the incoming URL path and return a redirect response when the condition matches.
Example: URL-Based Forwarding Instead of Redirect
Sometimes teams say "redirect" when what they really want is application-layer routing. In that case, use a forward action.
The client keeps the same visible URL, but ALB forwards the request to a different backend target group.
When ELB Alone Is Not Enough
If you are using Classic Load Balancer or Network Load Balancer, URL-based redirection is not the right expectation. Those products are not designed for full HTTP path logic.
In that situation, the alternatives are usually:
- switch to Application Load Balancer
- perform redirects in the application itself
- use CloudFront or another HTTP-aware layer in front
So the real answer is not simply yes or no. It is yes with ALB, no for older or lower-layer options.
Common Pitfalls
A common mistake is saying "ELB" generically and then expecting all load balancer types to support the same URL logic. They do not.
Another mistake is confusing routing with redirection. Forwarding to a target group is not the same as sending a 301 or 302 back to the client.
People also often forget that ALB rules are evaluated by priority. A broader earlier rule can shadow the redirect rule you expected to run.
Finally, do not overlook query strings, hostnames, and path rewriting details. Redirect behavior is often correct only when the full destination URL is specified carefully.
Summary
- URL-based redirect behavior is supported by Application Load Balancer, not by every ELB type.
- ALB can both redirect and forward depending on the rule action.
- Use redirect actions when the client should receive a new URL.
- Use forward actions when only backend routing should change.
- If you are on Classic ELB or NLB, a different layer is usually needed for URL-aware redirects.
Related reading
- Can I change the root EBS device of my amazon EC2 instance?
- Can I delete an item using DynamoDB Mapper without loading it first?
- Can I delete data rows in tables from Athena?
- Can I force CloudFormation to delete non-empty S3 Bucket?
- Can I access my Kubernetes Dashboard via DomainName pointing to specific server instead of localhost
- Can I make http requests directly to the janusGraph server?
- Can I limit concurrent invocations of an AWS Lambda?
- Can I pause an ECS service instead of deleting it?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.