Oliver Giesen
Oliver Giesen

Reputation: 9439

How to rewrite "id" url-parameter on a Joomla installation?

We have accidentally sent out a number of emails to customers with incorrectly formatted links. In particular, a URL parameter was named "id" where it should have been "ri". I'm having a hard time setting up a rewrite rule that handles these links and takes customers to the correct place anyway. It seems that Joomla is always "snatching" up the "id" parameter before my Rewrite rules apply and misinterprets it, thus leading to unnecessary 404 errors.

This should in theory work:

RewriteCond %{QUERY_STRING} id=([slg][^&]+)
RewriteRule ^([den]{2}/)?product/(.*)$ $1product/$2?ri=%1 [L,R=301]

In fact, when I replace the "id=" with something like "xyz=" then it does indeed work. However, no such luck with "id".

I have SEF-links and rewrites enabled in Joomla. The above rule is in the .htaccess file in the root folder (which also contains the Joomla default rewriting rules). Joomla-version is 2.5.14 . What do I have to do to make this work?

Upvotes: 0

Views: 268

Answers (2)

Wolfgang Blessen
Wolfgang Blessen

Reputation: 1029

THere is no way for joomla to take action before the .htaccess

If you have that condition at as the first one, I would remove the L Parameter, because it can keep Joomla from building its own rewrite rule.

If you want to check, if the condition is met, simply write a rewriteRule http://www.google.com [L], to check if, the ID= Parameter is really identified

Upvotes: 1

anubhava
anubhava

Reputation: 785286

Few suggestions

  • I would advice adding QSA flag. This will keep both id and riparameters in resulting URL and then let different codes take whatever parameter they want
  • Make this rule as first rule
  • Test in a different browser to avoid 301 caching issues

Suggested rule:

RewriteCond %{QUERY_STRING} (?:^|&)id=([slg][^&]+) [NC]
RewriteRule ^([den]{2}/)?product/(.*)$ $1product/$2?ri=%1 [NC,QSA,NE,L,R=301]

Upvotes: 0

Related Questions