URL Rewrite help!

Folks,

i have a people search website. in that i have the index.php form with following text boxes on it.

  1. First Name
  2. Last Name *
  3. State
  4. City
  5. Street

User must fill atleast last name for a people search.
The form submited as url encorded in to peoplesearch.php.

now i want to rewrite the urls like this(what ever the better and simple way to hide the encorded url’s from mysql hackers).

I though of making rewritten url’s like this :

if Last Name only entered : mysite.com/lastname.html
if First name and last name entered : mysite.com/firstname-lastname.html
if First Name and Last Name and State entered : mysite.com/firstname-lastname-state.html

like wise there may be many more combinations possible. But i am confused. how many combinations? i am well enough if i write what ever the url my form generates in to just a single result.html file.

Please advise me anything simple to hide the encorded url’s altogether.

Also you dont need to think about seo part here. coz i have generated url’s search engine friendly url’s for all there records in db. but the address bar url rewriting is only confusing me :rolleyes:

:slight_smile:

afridy,

It appears as if your “specification” is confusing you - it does me!

Okay, I believe that you’ve just started thinking about this search function and have not taken it anywhere as yet. What does your script need to perform the search? Last name? First initial and Last Name? First and Last name? State? State and City? State, City and Street? Before you get into rewriting URIs, you really should know what your script (and database) is capable of doing and with what input!

IF you can get that far, consider how your search terms can be differentiated in a URI so that your script can handle the input (to do something useful). Knowing that, you can then create useful URIs (to provide the fields) and ONLY THEN will you have the pieces (“new format” URI and serve-able URI) to start looking at mod_rewrite redirections.

Don’t put the cart before the horse! If you can’t create a good specification, your code will be useless.

Regards,

DK

Hai dklynn,

I just pm’d you the website i am talking about. just have a look at it when you free.

af,

Okay, nice work so far. HOWEVER, WHAT (“specificity,” if you please) are you asking for? Other than that, the form’s get action with all the values seems to do the job properly (you’re missing a few “continue for more matches,” etc., buttons on the results pages) so I’m impressed with the behind the scenes searching of databases with mapping, too!

Because you’d have to “jump through hoops” (with JavaScript) to change the default action of ALL browsers to alter the linkage, I have to ask WHY go to that bother when it’s working so nicely (IMHO, you’re at least 95% there!).

now i want to rewrite the urls like this(what ever the better and simple way to hide the encorded url’s from mysql hackers).

I though of making rewritten url’s like this :

if Last Name only entered : mysite.com/lastname.html
if First name and last name entered : mysite.com/firstname-lastname.html
if First Name and Last Name and State entered : mysite.com/firstname-lastname-state.html

WHY? That’s basically the “loopy” redirection discussed in my signature’s tutorial. IMHO, it’s not worth the effort. For instance, what happens if someone has a hyphenated last name? Smythe-Jones would LOOK like Smythe is the last name and Jones the first name. IF you’d read the tutorial, you’d know that I prefer _'s (How many people have names with _'s? How many words have _'s?) but that could still cause problems because you only require one key value of five. Normally, you’d have a succession of values with all previous values REQUIRED for each succeeding value but that does not seem to be the case for you (Last+NOFirst+NOState+City+NOStreet?).

With such a hodge-podge, I’d think that you’d need a special handler script to accept the form’s query string then convert to URIs of your choosing, probably with a digital code to let the NEXT handler script which values are present and in which order. ONLY then can mod_rewrite get involved … but it would be easier to have the first handler use a header(“Location:”) redirection (with a header(“Status:301”)) to a second handler to reassemble the original URI for a NON-301 redirection to your peoplesearch script.

Did that make you dizzy? Again, IMHO, it’s not worth it as your effort thus far is VERY good!

Regards,

DK

Thanks dklynn,
clearly undestood!
Mean time ill have a look at your article surely today…
:slight_smile:

af,

Clearly understood? It made me dizzy! :lol:

Regards,

DK