Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Custom .htaccess help needed—anyone with mod_rewrite experience? 
Scott Munn
Jr. Member
Total Posts:  19
Joined:  2009-09-04


My team and I are working on redirecting outdated links to our store (with the URL scheme from a previous store package) to the search function of Magento.  However, we are having some serious troubles with it.  I searched some of the other threads on here regarding htaccess but no one had seemed to come across a resolution, so I wanted to see if anyone with mod_rewrite experience could just take a look and see if our rule is written incorrectly.

RewriteCond %{THE_REQUEST} ^servlet/(\w+)?$ [NC]
^servlet/(\w+)$  index.php/catalogsearch/result/?q=$1

Basically we want any old URL from to go to  How can we get this working?

Thanks for all of your help!

Magento Community Magento Community
Magento Community
Magento Community
Total Posts:  767
Joined:  2007-12-29

The problem is the question mark in the URL - no matter where you move it in the .htaccess or the httpd.conf it will not work. The solution I came up with was to place some of the cms pages in the htaccess/httpd.conf and then use a modified version of the mxperts sku-in-the-url plugin. This looks for prod=xxxxx strings and also for cat=xxxxx strings. On top of that I was able to have a couple of lookup arrays for anything that was missed. I took the ‘more results from...’ URL’s that were on google and made sure that every single one went to where I needed it to go.
This solution was more elegant because it copes with multi-store, also the apache is not stuffed with huge lookup tables. I also was able to avoid doing the catalog search that you seem to be heading for, it goes straight to the page.
I would like to put what I have out here or on the wiki for the benefit of others, but it would take me a little while to strip out the site specific stuff and I just have not had time for that. PM me if you want the files, or, if you are selling anything worth having then I am sure we could come to an arrangement wink

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top