I have a little project integrating a 3rd party application, which seems pretty easy and straight forward for the most part. However, it requires some internal Routing to be set in place, in order to work, along with some Pass-Through Redirects.

Joomla Redirect plugin doesn't allow for this, so my idea is to use .htaccess to achieve this. I'm not much good with htaccess, and don't understand Joomla routing deep and well enough to modify it or create custom components... but this is the furtherest I've gotten with htaccess rewriteRule:

RewriteRule ^/product/* /product/$1 [QSA,PT]

The idea is to have a Joomla article with a specific DIV tag, where the product details will be loaded into. This div is located at: /product/ When the user clicks on a product to view details, the URL will change to: /product/product-name

This does not exist in Joomla, so you get a 404 error. The RewriteRule is supposed to point everything after /product/* to /product/, but leave the URL structure intact.

As I understand it, a Pass-Through redirect shouldn't result in a 404 error, so I must be missing something?

Out of curiosity, I tried just this rewriteRule to see if it actually triggers:

RewriteRule ^product/* /collection/$1 [QSA,PT]

It does not work, /product/ is still in the URL. However this exact rewriteRule works in an online htaccess Tester: https://htaccess.madewithlove.com?share=a7610055-95fd-4ed1-9f12-d60f14e44358

I must be doing something wrong, but I've been working on this for a week and haven't gotten anywhere. I hope someone here has the answer.

  • Could you clarify your problem a little? I think you have a single article menu item at /product and a non-joomla php application in the directory /product - is that correct? Mar 16 at 21:54
  • this 3rd party app is run by javascript that pulls data from an external site, then displays it inside a div. This div is in a Joomla article, linked to the menu item /product/ When a user clicks on a product, which is pulled from the external site, Joomla routing should display the article at /product/ while the URL will be deeper, example: /product/product-name I hope this makes more sense. Mar 17 at 2:27
  • Ah ha. You're trying to send traffic from product/* back to product. Unfortunately that can't work because all the Joomla traffic is already going through the index.php and then being processed by the Joomla router. You'll need a very barebones component to do what you are after. Alternatively - you can just use a query string or hash on the end instead of a proper path segment, but I presume that you know that. Mar 17 at 3:41
  • Yes, that sounds right. Truth is, the 3rd party app doesn't provide much info, just says to create some routes, then use pass-through redirect to the pages containing the div tags. Like I said in OP, I'm not capable of creating a component, but happy to pay someone to help me or do it for me. I wish I could say you presume correctly.. but I can't. Any chance you can elaborate? maybe with an example that I can try? Thanks James, really appreciate your help mate. Mar 17 at 4:06
  • Difficult to know how to exactly do it without knowing what the javascript looks like, but basically if your links end up like /product?product=product-name then you could do: const urlParams = new URLSearchParams(window.location.search); const product_name = urlParams.get('product'); and then pass product_name to the 3rd party application to retrieve the data Mar 17 at 5:12


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.