In content management systems, URLs are often not always fixed in advance and are therefore not statically created in advance (as a contribution or menu item), but address objects from the database. Similar to WordPress ( as described here ), it is also possible in Joomla to build dynamic URL structures (independent of the internal alias system). Either JRouter can be used here - or you can use a one-liner in .htaccess.
First you create a menu item (e.g. with the alias "subfolder") and let it point to a prepared post (e.g. with the ID 1337) Then you put the following rule in the .htaccess directly after the introductory line RewriteEngine On :
RewriteRule ^subfolder/([^/]*)\.html$ /index.php?option=com_content&view=article&id=1337&name=$1 [L]
Then you get the URL after calling up
https://tld.com/subfolder/foo.html
the content of the page
https://tld.com/subfolder/?name=foo
In the above-mentioned article (or the modules connected to the menu item), the exact URL can then be easily queried with $ _GET ["name"]. If you are working with IIS instead of Apache, you should add the following instruction to the .htaccess equivalent (in the web.config):
<rule name="custom route 1" stopProcessing="true">
<match url="^subfolder/([^/]*)\.html$" ignoreCase="false" />
<action type="Rewrite" url="/index.php?option=com_content&view=article&id=1337&name={R:1}" appendQueryString="false" />
</rule>