0

I have a bunch of domains passing to a Resin cluster through an HAProxy. The idea is, when I receive a 404 because of a non-existent subdomain, I want to redirect it to the existing page, like this:

test123 is a non-existing subdomain, so if I make the request http://test123.mydomain.com/rents-house-near-the-lake.html I want to redirect it to http://www.mydomain.com/rents-house-near-the-lake.html

(Where www is an existing subdomain)

This will be possible? Thanks!!

Masterl1nk
  • 157
  • 2
  • 13

1 Answers1

2
  1. Create an ACL to match for the www subdomain: acl is_host_www hdr(Host) -i www.mydomain.com

  2. If the acl is not matched, return a 3XX redirect: redirect pfx http://www.mydomain.com unless is_host_www

Florin Asăvoaie
  • 7,057
  • 23
  • 35