What you need to do is have a DNS entry set for moodle.mydomain.com with who ever does your DNS. this will allow moodle.yourdomain.com to point to your server.
You also need to setup your server to point to the required /opt location for requests from moodle.yourdomain.com. Use either with a custom template or do things the easy way with the SME sitemaker contrib which creates the necessary templates for all the required appache configuration for you.