Forum Moderators: phranque
RewriteEngine on
RewriteRule ^([A-Za-z0-9-_-]+)/([A-Za-z0-9-_-]+)/?$ index.php?primary=$1&secondary=$2 [L]
for example: if I put http://example.com/about/people - it works fine. if I put http://example.com/about/ - this doesn't. how do I make it work if one of the variables isn't set?
thanks
[edited by: jatar_k at 7:09 pm (utc) on April 4, 2007]
[edit reason] please use example.com [/edit]
RewriteEngine on
#
RewriteRule ^about/people/?$ index.php?primary=about&secondary=people [L]
#
RewriteRule ^about/?$ index.php?primary=about [L]
#
RewriteRule ^people/?$ index.php?secondary=people [L]
# -or, if "people" is always under "about":
RewriteRule ^people/?$ index.php?primary=about&secondary=people [L]
Categorization --putting the URLs to be rewritten into classes or groups that always share a common "method" for being rewritten-- is the biggest part of the job; Once this is done, writing the code is relatively easy. The more consistent and 'formal' the rewriting methodology, the fewer rules you'll need to use.
Also, the possible variations on dynamic names/values and their placement in the static URL are endless, so the above may not be what you really need.
Jim