Search code examples
.htaccessjoomla

Joomla redirect query string with .htaccess


How to redirect https://www.themaidsofcharleston.com/?Itemid= to https://www.themaidsofcharleston.com/

I have tried

RewriteCond %{QUERY_STRING}  ^?Itemid=$
RewriteRule ^/$  /?  [R=301,L]

but id doesn't work

Thank you in advance.


Solution

  • Two issues needed fixing here:

    • {QUERY_STRING} does not contain the leading question mark - you want to check for ^Itemid=$

    • when configuring rewriting in .htaccess context, the path never starts with a /, that has been stripped off at that point already. So your rule needs to match an empty path instead, ^$