5

I have Url as:

localhost/ab/directory.php?id=200

id=200 is jenny id member

how to change it to

localhost/ab/jenny

is possible?

Thanks

TarangP
  • 2,560
  • 5
  • 18
  • 35
Iwan
  • 51
  • 1
  • 1
  • 2

3 Answers3

11

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/

Sampson
  • 251,934
  • 70
  • 517
  • 549
1

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
  • 147,774
  • 24
  • 184
  • 187
  • 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 Dec 11 '09 at 06:01
  • @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 Dec 11 '09 at 06:04
  • 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 Dec 11 '09 at 06:09
  • @Iwan: See the link in @Jonathan Sampson's answer. – Asaph Dec 11 '09 at 07:06
0

Check This: http://www.wmtips.com/apache/how-use-mod-rewrite-url-rewriting.htm

s-sharma
  • 1,867
  • 1
  • 15
  • 20