I don't believe you can change or remove the /api
within Joomla as it is hard coded into the processing of the URI found in libraries/src/Uri/Uri.php
, see code below at the last line.
if (trim($live_site) != '')
{
$uri = static::getInstance($live_site);
static::$base['prefix'] = $uri->toString(array('scheme', 'host', 'port'));
static::$base['path'] = rtrim($uri->toString(array('path')), '/\\');
if (\defined('JPATH_BASE') && \defined('JPATH_ADMINISTRATOR') && JPATH_BASE == JPATH_ADMINISTRATOR)
{
static::$base['path'] .= '/administrator';
}
if (\defined('JPATH_BASE') && \defined('JPATH_API') && JPATH_BASE == JPATH_API)
{
static::$base['path'] .= '/api';
}
}
I do think it should be possible with .htaccess to insert the /api
into the URL for Joomla without having to do a redirect, however I don't have a working example I can provide you with.
Search for examples of rewriteCond
and rewriteRule
for ways to insert /api
to your incoming URI/URL.
rewriteCond %{http_HOST} ^www\mydomain\.com\.au$
rewriteRule (.*) /site2/$1 [L]
I use these two lines to append a folder to a URL so what you need to do is insert /api
to the URL before /v1
.
Your condition statement would have to be more specific to your API's URL so as not to interfere with other API's in your instance, i.e. you don't want to end up creating yourdomian/api/api/otherapi
.