On our website using Joomla we have duplicate URLs for the same page being found by Google Webmaster Tools. For instance the following URLs go to the same page on our site:
- /lawson-equipment/auxiliary-equipment/poly-pro-sinks?option=com_content&view=article&id=75&Itemid=74
- /lawson-equipment/pre-press/poly-pro-sinks/index.php?option=com_content&view=article&id=75&Itemid=74
- /technical-support/digital-learning?option=com_content&view=article&id=75&Itemid=74
- /lawson-equipment/textile-equipment/dryers/encore-dryer
with the fourth URL being the actual path I want. How would I go about formulating a rewrite rule that would grab any URL query strings with "&id=75" to be directed to the SEF URL without doing a Redirect 301 for each of the incorect URLs? This happens often.
Success! Using a
RewriteCondcommand with a common snippet from the non-SEF addresses, and aRewriteRulecommand for the target address using regular expressions I come up with the following for my .htaccess file:So far this seems to be working and hasn’t affected anything else that I can see. Please feel free to comment or add another answer if there is a better way of doing this!