I created a new storeview accessible under the URL app.example.com
I added this to the .htaccess to set the MAGE_RUN_CODE Environment Variable to app if the URL app.example.com is called:
SetEnv MAGE_RUN_TYPE store SetEnvIf Host ^example.com MAGE_RUN_CODE=default SetEnvIf Host ^www.example.com MAGE_RUN_CODE=default SetEnvIf Host ^app.example.com MAGE_RUN_CODE=app SetEnvIf Host ^www.app.example.com MAGE_RUN_CODE=app
Then I changed the base url of my new store view to http://app.example.com/
I created a new CMS page for the new storeview with the URL Key
But if I try to access it via app.example.com/app-test, then I get redirected to https://www.example.com/catalogsearch/result/?q=app+test
I tried to reindex and flush cache, but it made no difference.