Dynamic URLs in Joomla

In content management systems, URLs are often not predetermined and therefore not created statically (as posts or menu items) in advance, but rather access objects from the database. Similar to WordPress ( as described here ), it's also possible to create dynamic URL structures in Joomla (independent of the internal alias system). This can be achieved either with JRouter – or with a single line of code in the .htaccess file.


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&amp;view=article&amp;id=1337&amp;name={R:1}" appendQueryString="false" />
</rule>
Back