• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

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!
0
jimday1982
Asked:
jimday1982
1 Solution
 
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now