(inspired by Janek's comment)
If your Apache instance is configured for * smoothing, then there is no need to create a virtual named host. You can fake it using PHP by evaluating $ _SERVER ['HTTP_HOST'].
To determine if your Apache instance will handle it, edit the local / etc / hosts file (or the Windows equivalent -% SystemRoot% \ system32 \ drivers \ etc \ hosts) so that the desired virtual name points to your server.
for instance
# An example HOSTS file. 192.168.1.4 testserver testserver.com subdomain.testserver.com secondname.com
Suppose 192.168.1.4 is the IP address of your server. Everything after that is an alias that can be called by the server.
Then, when Janek suggested creating a page that would be echo $_SERVER['HTTP_HOST'] to see if it captures the name correctly. If so, then all that is required is a DNS change, and Apache can remain unchanged.
Otherwise, without access to Apache.conf (this type implies that you do not have access to many things), it will be difficult to implement. Programming will not - but the implementation will be.
That's why:
Apache will host virtual hosts by default. But you need access to the conf conf directory of the server (often located in /etc/httpd/conf.d/) so that you can create a “include” file for the virtual host (if Apache is configured to enable it), there should be recent installations).
You will need to be able to start Apache (reboot). Without this, the virtual host changes will not be affected.
You will need to change the DNS. You can always change your local / etc / hosts file, but in order for visitors to get to your site, you will need to skip the DNS change. (Which may instantly - or may take 24 hours).
Scripts can certainly be executed (see Cpanel and WHM)
source share