I'm managing a LAMP stack and have tried to get a subdomain to redirect to an external url. We are running Apache 2.2.22 (Debian).
I have created a simple virtual host to redirect to the external url:
<VirtualHost *:80>
ServerName sub.mydomain.tld
RedirectPermanent / https://outgoing.url/
</VirtualHost>
After enabling the virtual host and reloading apache2 the subdomain works correctly for browsers that haven't visited the main site before and incognito windows, but if I have visited the main site before it will redirect to the main site.
I'm guessing it is a caching problem, but I can't figure out how to fix it so that visitors that have visited the main site before can visit the subdomain without clearing their cache.