'API or template folder redirect in htaccess

I have a directory structure as follows:

.htaccess
api.php
template/index.html

When calling domain.com/api/someendpoint, the request is forwarded to api.php.

# enable apache rewrite engine
RewriteEngine on
# Deliver the folder or file directly if it exists on the server
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !-d
# Push every request to api.php
RewriteRule ^(.*)$ api.php [QSA]

now, when calling domain.com, the request should be called to the index.html in the template directory:

RewriteCond %{REQUEST_URI} ^$
RewriteRule . template/index.html [QSA]

this does not work, the directoryListening is always displayed.

What is the correct way to get the index.html?



Sources

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

Source: Stack Overflow

Solution Source