Migrating a Joomla 3 component to Joomla 4 I have problems with getting Apache Server htaccess correctly configured to append query string from request to substituted URL - QSA flag. - It looks like this affects other Joomla components as well. Here an example of an RewriteRule which works in Joomla 3 but produces a 404 in Joomla 4:

RewriteRule ^testpage$ /index.php?option=com_content&view=article&id=1 [QSA,L]

It redirects but does not retain the original request when I change the rule to do so:

RewriteRule ^testpage$ http://mydomain.com/index.php?option=com_content&view=article&id=1 [QSA,L]

This is what the user sees in the browser's address bar: http://mydomain.com/index.php?option=com_content&view=article&id=1

Is it just me? What am I missing?

  • What is the context or background to what you are trying to do? Please provide an example of the original URL in full that contains testpage so we can see the before and after of what you have and what you want. I have a couple of ideas of what you might be trying to do but without some more details I would be just guessing at a solution.
    – Irata
    Commented Aug 11, 2023 at 4:46
  • Well, http://mydomain.com/testpage should stay in the address bar of the browser, but it redirects to the underlying component http://mydomain.com/index.php?option=com_content&view=article&id=7.
    – cappu
    Commented Aug 11, 2023 at 9:31
  • This Joomla component serves a printer supplies shop link with manufacturers druckertinte.de/hersteller, categories druckertinte.de/canon-modellserien, printer models, item lists druckertinte.de/canon-pixma%20ip%203600-ida8e0ef13 and item details. It relies heavily on htaccess redirects to find the appropriate records in the database. The links sends you to the current Joomla 3 version.
    – cappu
    Commented Aug 11, 2023 at 9:43
  • I am in the wrong country to to be able to view the link unfortunately. What I had in mind was the reverse to your requirement, remove the testpage but still go to the correct page.
    – Irata
    Commented Aug 11, 2023 at 10:50
  • 1
    No there won't be query string in the url. Anyways, I realised that I could write a custom router to achieve the same, and much more elegantly. docs.joomla.org/J3.x:Supporting_SEF_URLs_in_your_component
    – cappu
    Commented Aug 12, 2023 at 17:04

1 Answer 1


Looks like in Joomla there is a better way to solve this issue than using mod_rewrite. A big advantage seems to be that you do not have to rely only on the Apache server, i.e. if you want to use nginx.

Here some links I found on how to write a Custom Router in Joomla:

For Joomla 4

For Joomla 3

If you know of better tutorials, feel free to post your links to this topic.

Edit: This thread should also be helpful: Joomla 4 Router forward to Controller function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.