Forum Moderators: phranque
Both of the variables would always be defined.
The second method is for a category view:
/application/{{category_name}}/{{sorting}}/{{page_number}}
All of the variables would be optional. A user could call the following:
/application
/application/sorting
/application/sorting/23
/application/category_name
/application/category_name/23
/application/category_name/sorting/23
Is it possible to combine both of these somehow?
If not, can at least the URL's listed above work together :)
Heres what I have, but it confuses the category and sorting when one is missing.
RewriteRule ^appc/?([A-Za-z-_]*)/?([A-Za-z]*)/?([0-9]*)$ callback.php?request_type=display&category_name=$1&sort_by=$2&page_number=$3 [QSA,L]
However, if the category fields have something in common, and the specific_name fields have something in common, and the category and specific_name fields differ form each other in some identifiable way, then you can use a regex pattern to decide which is which and what is what. You may need to add/use prefixes or suffixes (e.g. "cat"), character ranges (e.g. "[a-z] or [0-9]" or variations) to the URL-path-parts in order to do this.
But since only you know the ranges and values that each of these fields can have, and whether those values "overlap" between fields, you'll have to try to "classify" these fields and their values, with the question in mind, "How do I tell a specific-name/unique-id URL from a category-name/sorting URL by looking only at the URL?"
If the answer is, "I can't," then the problem cannot be solved without introducing some additional 'keys' into the URL, as in the "cat" prefix/suffix mentioned above, or any other method you prefer. Bottom line is that the information to allow determining the "URL-type" must be present (in some form) in the URL itself.
You could of course replace "/application" in the URL with "cat" and "prod" as appropriate, and then rewrite both cat and prod requests to the same callback.php script *after* determining which type of URL you need that script to handle.
When I speak of replacing or adding elements to the URLs, this must be done in the links on your pages themselves, because that is where the URL is defined, and those are the URLs that will be sent to mod_rewrite on your server when the links are clicked.
Jim