mod_rewrite help

This seems pretty simple, but I cannot get it to work for the life of me...

I'm looking to turn these urls:  http://www.drunkdrinks.com/category.php?letter=a

into:  http://www.drunkdrinks.com/mixed_drink_recipes_letter/a

and http://www.drunkdrinks.com/category.php?pagenum=0&catid=8

into:  http://www.drunkdrinks.com/mixed_drink_recipes_category/0/8

Anyone know how to do this?  Thanks in advance!
jimday1982Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

radical_mitCommented:
Hello,

I would try and just the $_POST option within the <form> on the page before, these look like you are using $_GET

so set you <form action="to the sub page" method="post">
this should hide the ?letter=a for you .
this might just help you with you problem.
T
0
jimday1982Author Commented:
Not really sure what you're talking about here - I'm not trying to mess with my forms (yet, anyway), I'm just trying to make some of my links more SE friendly.  Thanks for your reply though.
0
brozzisCommented:

are you sure you want to solve this one with mod_rewrite ?

place this code at the begin of the php file "mixed_drink_recipes_category"
without extension. Remember to instruct your web server to use php to serve this file
I placed this code in a file tokenizer.inc included whenever necessary,
<?php
  if (strstr($PATH_INFO, "/")) {
   $p = substr($PATH_INFO, 1);
   $e_path = explode("/", $p);
   $i = 0;
   while ($i < count($e_path)) {
    $name = $e_path[$i];
    $val = $e_path[$i+1];
    $$name = $val;
    $i = $i+2;
   }
  }
?>

in a file "myFile" without extension and then call it like this:

http://myServer/myFile/param1/value1/param2/value2...

it should be quite straightforward to modify this to accept a well defined order of parameters, like you want:

http://www.drunkdrinks.com/mixed_drink_recipes_category/0/8

bye...

0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

basiclifeCommented:
Ok, I don't know the answer because I'm after something similar myself but I just want to tell you you are going the right way about it - using mod_rewrite to convert "subdirectories" which don't exist into parameters for a PHP / other CGI script. Not sure why noone else is seeing it that way
0
basiclifeCommented:
brozzis: The server would just return a 404 error without mod_rewrite wouldn't it?
0
brozzisCommented:

no mod_rewrite is necessary, and still it works.
I used the "tokenizer.inc" to hide parameters in GET calls, this is currently working.
Server-side you must force on apache the use of php for every file requested,
without checking for a .php extension, or use mod_rewrite to convert your calls
FROM /mixed_drink_recipes_category TO /mixed_drink_recipes_category.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
basiclifeCommented:
Hmmm. Nice workaround. I might haev to play with something like that. You learn something new every day. Thanks
0
brozzisCommented:

I gave a full and working solution...
I think that basiclife should admit this...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.