I am using EC2 and Route 53 of AWS(amazon web service) and LAMP(Apache, MySQL, PHP) of Bitnami.
I am trying to run two wordpress sites independently:
...local_path/htdocs/subsite1
...local_path/htdocs/subsite2
I want to access these subsites using subdomain like following:
subsite1.mydomain.com → ...local_path/htdocs/subsite1
subsite2.mydomain.com → ...local_path/htdocs/subsite2
Moreover, I want to switch where "mydomain.com" and "www.mydomain.com" when I want to(maybe once or twice a year). Specifically, I want to switch between Case A and B when I need.
Case A :
subsite1.mydomain.com -↘︎
mydomain.com ----------→ ...local_path/htdocs/subsite1
www.mydomain.com ------↗︎
subsite2.mydomain.com → ...local_path/htdocs/subsite2
Case B :
subsite1.mydomain.com → ...local_path/htdocs/subsite1
mydomain.com ----------↘︎
www.mydomain.com ------→ ...local_path/htdocs/subsite2
subsite2.mydomain.com -↗︎
I tried to combine DNS(AWS Route 53), VirtualHost, mod_rewrite and/or htaccess following several internet articles, but it was not successful, though I think there is several way to realize it.
What is the best way to resolve this, considering security and convenience? and How should I set them? Thank you in advance!
(SELF-ANSWER)
I resolved it using VirtualHost.
Especially in the case of "mydomain.com" and "www.mydomain.com", I used ServerAlias.
First of all, I registered A records for my server's ip:
Second, in the config file for VirtualHost, (in my case, .../apache2/conf/extra/httpd-vhosts.conf)
It works great!
Reference (Koreaen articles about VirtualHost)