tags:

views:

408

answers:

4

I have syntax : 'localhost/ab/directory.php?id=200'

id=200 is jenny id member

how to change be 'localhost/ab/jenny' in address bar? is possible?

Thanks

+4  A: 

You'll want to use mod_rewrite, a module available in apache. This will be managed by an .htaccess file within your web directory. AddedBytes has a nice tutorial for beginners on url-rewriting.

See: http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/

Jonathan Sampson
+1  A: 

You can do this in at least 2 different ways:

  • Use mod_rewrite for Apache to map the SEO friendly URL to your querystring based URL.
  • Make /ab a php script that inspects the PATH_INFO to retrieve /jenny. You'll have to configure Apache to treat scripts with no extension as php scripts for this to work.
Asaph
i interest for ponit 2.'localhost/ab/directory.php?id=200', sorry 'ab' is my project.sample: i have home.php, in home.php i call localhost/ab/directory.php?id=200 using href. and then i wan to direct to directory.php, but i want to change in address bar be 'localhost/ab/jenny'.in directory.php, only get jenny and call mysql to get detail name,address, etc.Can you give sample for point 2, sorry my english bad.thank you
Iwan
@Iwan: I'm sorry, in order for option 2 to work, `/ab` would have to be an actual php script, not a directory as it is in your case. I suggest you go with option 1 as it is the more widely practiced and accepted of the 2 approaches.
Asaph
ok. i am so interest your option 2.but my site is running. any problem if i do that? can you give sample for my problem..please..thank you.
Iwan
@Iwan: See the link in @Jonathan Sampson's answer.
Asaph
+1  A: 
See: http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/
bala3569