Forum Moderators: phranque

Message Too Old, No Replies

Clean URL's with query string at the end

         

justinl604

7:41 pm on May 5, 2009 (gmt 0)

10+ Year Member



Hello everyone,

I'm attempting to mix clean url's with query strings. This is for an online shopping catalogue.

The shopper is able to browse different categories of the store. Within each category page, there can be hundreds of items, so there is a need to have multiple pages and also to be able to sort the pages by price, or by name, etc.

What i'm trying to accomplish is to get a URL similar to what Etsy has on their site:

[etsy.com...]

They have the clean url for "category/books_and_zines" but then they strip the .php and have the query string following ?order=date_desc&page=3

Basically I just want to have the $_GET query string be able to append onto the end of the clean url. Does anyone know of the rewrite rules to achieve this?

Right now I have this working:
RewriteRule ^category/([A-Za-z0-9-_]+)$ view_category.php?category=$1

outputs:
/category/monitors_lcd

Please let me know if you need more information from me as I'm fairly new to this stuff.
Thanks again to anyone who is able to shed some light on this.

justinl604

8:26 pm on May 5, 2009 (gmt 0)

10+ Year Member



Looks like [QSA] was the answer.

All that was necessary was adding [QSA] at the end of my rewriteRule as so:

RewriteRule ^category/([A-Za-z0-9-_]+)$ view_category.php?category=$1 [QSA]

Thanks to ChadSEO and j_a_c_k for their previous post found here: [webmasterworld.com ]

g1smd

11:29 pm on May 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Add [L] to the end of every Rule unless you know exactly why it needs to be omitted for that rule (rare!).

justinl604

11:33 pm on May 5, 2009 (gmt 0)

10+ Year Member



Thanks g1smd! I'm so new to this. Tips like that are really helpful :)

jdMorgan

11:45 pm on May 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll find that our Site search (link at top of page) is really useful for finding tips. Most problems have been covered in-depth here, and although the threads may not solve your exact-same problem, they'll usually get you going in the right direction, or at least give you the "vocabulary" to ask focused questions.

When deciding what info to move from the query string into a "clean" or "SEO-friendly" URL, consider what is useful in public search results, and what is not: Category and product pages are generally useful, while on-site search sort key, sort order, page counts, purchase quantities, and other searching/buying-related parameters are not worthy of an additional public search engine listing. So a URL of exampe.com/shop/category/product-type/product-color/product-size/specific-item?quantity=3 is a pretty good set-up.

[added] See our Apache Forum Charter for links to some useful resources. [/added]

Jim

[edited by: jdMorgan at 12:01 am (utc) on May 6, 2009]

g1smd

12:48 pm on May 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't like category or product-type to appear in the URL if there is any possibility that it could appear under multiple entries.

In fact in much prefer a single ID for a product page: example.com/item9372261617

The database can hold the data as to what category indexes, colour indexes, size indexes, brand indexes, and offer indexes it can appear in - without reflecting any of that stuff out into the URL.