2

A website example.com has one subdomain a.example.com. The point here is I want to redirect all existing and non existing subdomain (ex- b.example.com) to example.com without changing URL(URL MASK). To explain it more further, when a user enters b.example.com he must see example.com on his screen but URL must not change from b.example.com --> example.com. I think its possible from .htaccess file but I failed to achieve it.

Do I need to configure virtual host. Since I only have access to .htacces, I wish I can get it done

0ffliner
  • 31
  • 5

1 Answers1

1

You need to have two things configured correctly:

  1. A DNS entry with wildcard (*.example.com -> your server IP)
  2. A virtual host with wildcard alias (ServerAlias *.example.com)

Then there is nothing to do in .htaccess. .htaccess alone can't do what you want. And please note also that this could be SEO-toxic (duplicate content), but it depends on your use case.

As you do not have access to virutal hosts config, may be you could go with subfolders instead of subdomains.

Zimmi
  • 1,599
  • 1
  • 10
  • 14