This explanation assumes your Joomla instance is in /public_html/testing
and the URL will be www.example.com
without the '/testing'
string appearing in the URL.
To run Joomla in a sub directory you need need to update the $live_site
so that it contains just the domain name, no mention of the sub-directory, eg.
$live_site="https://www.example.com',
In the /public_html/.htaccess
you then 'hide' the sub-directory name with a little bit of code
# Internally Rewrite requests for Example to hide the sub-directory in the URL
# when using the primary cpanel domain rather than an Add-on domain.
# If the target directory holds a Joomla instance then the configuration.php
# entry for $live_site needs to contain the full domain name also, eg.
# $live_site='https://www.examle.com' for this hack to work.
#
# The $ 1!^directory allows you to access other directories and not be affected by this,
# eg. www.example.com/anotherdirectory
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond $1 !^anothedirectory
RewriteRule (.*)$ /testing/$1 [L]
Some things to note is that above normally only needs to used when the hosting account, eg. cPanel, forces the primary domain to use the /public_html/
root folder. For all other domains then use sub-domains or Add-on domains.
From the point of view of the extension being developed you should not need to be concerned about any of the above if you use the normal methods to let Joomla resolve the domain and/or prefix the directory names in your code.
This approach has worked since Joomla 1 and still works with Joomla 4.