Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By nikhilsukul on
I need to create sub domains on the fly, and i need to show the content depending upon the sub domain.
For example:
i need to convert the url like
www.mydrupal.com/q=cricket to cricket.mydrupal.com,
and both urls should display extactly the same content coming only from one database.
The idea of creating different sub folders within the sites/default is not acceptable as i don't know, like the above example how many sub domains in need to create depending upon the taxonomy
Comments
Apache wildcard virtualhost?
It is more Apache config question then Drupal performance issue.
Apache supports wildcards in virtual hosts and I've heared some hosters allow to add "*.mydomain.com" domains. All third level domains will be directed to a single Drupal installation directory in which you may use mod_rewrite to move third domain to a query parameter, after that you can check this parameter against your taxonomy, serve content or 404. I never done that myself.
Not working
Thanks for the reply, actually i added the following in Apache:
DocumentRoot "/drupal"
ServerAlias *.mydrupallocal.com
ServerName www.mydrupallocal.com ........
but , if i type anything.mydrupallocal.com, it just shows page cannot be found!!!
And you have
And you have anything.mydrupallocal.com defined in nameserver and 'host anything.mydrupallocal.com' returns the same IP as does 'host www.mydrupallocal.com'?