Forum Moderators: phranque
Example:
www.example.com/oldcart/mouse will show search results for "mouse"
I need to get similar results with my new cart but using Rewrite generators aren't producing the results I need.
New site example should be:
www.example.com/newcart/mouse and give results for "mouse" if searched for. But is just listing my Category called "mouse". I tried two totally different Rewrite rules but they both gave similar results. Another example is:
http://www.example.com/shop/Bear It is in the "Bear" subcategory. But if you do a search for "bear" totally different results show up since not all bear decals are in the bear category.
# Enable Rewrite Engine
RewriteEngine on#Create friendly URL
RewriteRule ^shop/mouse$ shop/index.php?subcats=Y&type=extended&status=A&pshort=Y&pfull=Y&pname=Y&pkeywords=Y&cid=0&q=mouse&x=0&y=0&dispatch=products.search [L]
Of coarse I am a total newb to this...and trying to search for this type of question was pulling up all kinds of unrelated results.
[edited by: jdMorgan at 2:12 pm (utc) on Dec. 2, 2009]
[edit reason] example.com [/edit]
It may be simply that, your site design being new, it has not yet been fully-indexed; Category pages, usually appearing 'higher' in the site's internal linking structure, will be spidered and ranked first, and unless the search is specific to words that appear only on product pages, it's entirely natural that a category page may out-rank a product page.
Jim
So if I type into my url www.example.com/shop/bear should generate a search of my entire site for the word bear. This is how my old cart functioned using a rewrite.
The search string I used to generate the code shows all products on my site listing the word "bear". But the rewrite only goes to my category called "bear". That key term has to be an exact match to the category. The term "bear" works since I have a category called that. But example www.example.com/shop/dog does not work as my category for "dog" is "dog decals". I am not wanting the rewrite to just look for categories....it should search for the keyword in categories, product name, search words, etc. Here is the search string used.
http://example.com/shop/index.php?type=extended&match=any&q=bear&pname=N&pname=Y&pshort=Y&pfull=Y&pkeywords=Y&cid=0&category_name=All+categories&pcode=&price_from=&price_to=&weight_from=&weight_to=&dispatch[products.search]=Search
Oh, and sorry for including a real link to my site in the previous post.
At any rate, this search problem is due to the site's new architecture, and not to any problem specific to mod_rewrite. The search script will have to be modified to 'comprehend' this new architecture, and to issue searches for all categories. This may mean issuing consecutive searches using all possible 'friendly' category URLs, or (a better option) it may mean defining an additional friendly-URL-space such as example.com/search/<keyword> (where <keyword> is "bear" in our current example) that maps to your dynamic script query space using a 'category' parameter of 'all' or 'search' -- I'm just guessing here and throwing out some ideas, as I certainly don't know all the details of how your site works.
Jim
www.example.com/shop/bear gives results of the bear category ONLY. But I want it to search the entire site for the word bear; not just in the bear category.
www.example.com/shop/bear gives results of the bear category ONLY. But I want it to search the entire site for the word bear; not just in the bear category.
And that is what I directly addressed in my post above. I don't see that your search problem has anything to do with the type of rule you posted above, and it isn't because I don't understand what you've said or don't understand your rule. It's that your rule is for "shop" and and contains only the product "mouse", and now you're asking about the operation of your site search. If your site search now also uses 'friendly URLs' then those friendly URLs must contain all the information needed to do a cross-category search, and that's all I can really say about searches given what I read here.
Let me address your rule directly.. Maybe that will help, though I'm not sure it will:
#Create friendly URL
RewriteRule ^shop/mouse$ shop/index.php?subcats=Y&type=extended&status=A&pshort=Y&pfull=Y&pname=Y&pkeywords=Y&cid=0&q=mouse&x=0&y=0&dispatch=products.search [L]
It can redirect them to a different URL, telling the client "Please ask for what you wanted again at this different URL," and ending the current HTTP transaction (The client must start a new HTTP transaction by asking for the URL we just gave it -- if it elects to do so).
Alternately, mod_rewrite can simply re-map the incoming URL request to a different server filepath than that to which it would be resolved if no mod_rewrite code were present. And that is what you are doing with your rule here.
Instead of letting the server look at the real server directory "/shop" for a real file named "mouse", your rule takes that URL request, re-formats it, and passes it to your script as "shop/index.php?subcats=Y&type=extended&status=A&pshort=Y&pfull=Y&pname=Y&pkeywords=Y&cid=0&q=mouse&x=0&y=0&dispatch=products.search"
The URL requested by the browser is "example.com/shop/mouse", the script filepath is "/shop/index.php", and the query string parameters are "subcats=Y&type=extended&status=A&pshort=Y&pfull=Y&pname=Y&pkeywords=Y&cid=0&q=mouse&x=0&y=0&dispatch=products.search"
I don't know if that will help, but the terminology in both this post and my previous posts is precise; Distinguishing between URLs and filepaths is essential, as is an understanding of when mod_rewrite acts, and what it can do.
Jim
I used a couple of mod-rewrite generators to try and generate the proper rules for the code above. One didn't work at all. But 2 gave the same results I am having even though the rewrite rules were totally different. I'm not sure why the one I have in the example above works for other search terms besides "mouse" but it does. example.com/shop/mouse gives results for the mouse category. example.com/shop/bear give results in the bear category, etc. In any case both rules seem to be forcing the category in the results...not just a general query for the term. I thought an expert just may be able to look at the code and know instantly what the problem was but I guess it goes deeper than that.
My brain is scrambled trying to decipher all of this so I'm gonna take a break.
-----
RewriteRule ^([^/]*)$ /shop/index.php?subcats=Y&type=extended&status=A&pshort=Y&pfull=Y&pname=Y&pkeywords=Y&cid=0&q=$1&x=0&y=0&dispatch=products.search [L]
Jim