'Redirect multilevel subdomain to a folder .htaccess

I have a subdomain meet.example.com that points to the app folder and I want api.meet.example.com to point to the api folder.

The folder structure is like this

public_html - root folder

  • app
  • api

Then this is the rule that I have in my .htaccess I have in the root folder. The first rule works fine and opens the content from the app folder, but the second rule (api.meet.example.com) is not opening the content from the api folder.

RewriteCond %{HTTP_HOST} ^meet\.example\.com$
RewriteCond %{REQUEST_URI} !^/app/
RewriteRule (.*) /app/$1 [L]

RewriteCond %{HTTP_HOST} ^api\.meet.example\.com$
RewriteCond %{REQUEST_URI} !^/api/
RewriteRule (.*) /api/$1 [L]

What I am doing wrong here?

SOLUTION

Thanks for @anubhava question about the VirtualHost config I just realized that I did redirect both domains from one hosting to another, but didn't add both domains to the new hosting just the meet.example.com, assuming that as api.meet.example.com is actually a subdomain of the already added then I will not need to add it.

Adding api.meet.example.com as a domain to the new hosting fixed the issue.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source