Q:

Htaccess redirection to add string in all url with matching format

Pl advise
Incorrect URL
     www.abc.com/index.php?option=com_usedtoy&view=category&limitstart=495
     www.abc.com/index.php?option=com_usedtoy&view=category&limitstart=510
     www.abc.com/index.php?option=com_usedtoy&view=category&limitstart=525

Correct URL
     www.abc.com/index.php?option=com_usedtoy&view=category&Itemid=2&limitstart=495
     www.abc.com/index.php?option=com_usedtoy&view=category&Itemid=2&limitstart=510
     www.abc.com/index.php?option=com_usedtoy&view=category&Itemid=2&limitstart=525

How to add Itemid=2 in all url which match incorrect url format of usedtoy - which has Itemid missing
Edit
After using the htaccess code
New result is
     www.abc.com/index.php?Itemid=2&option=com_usedtoy&view=category&limitstart=90

A:

put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|&)option=com_usedtoy(&|$) [NC]
RewriteCond %{QUERY_STRING} !(^|&)Itemid=2(&|$) [NC]
RewriteRule ^index\.php$ %{REQUEST_URI}/%{QUERY_STRING} [L,NC]

RewriteRule ^(index\.php)/(option=com_usedtoy&view=category)&((?!Itemid=2&).+)$ /$1?$2&Itemid=2&$3 [L,NC,R=301]

