Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change URL Address make short in PHP

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

like image 201
Iwan Avatar asked Dec 11 '09 05:12

Iwan


2 Answers

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/

like image 105
Sampson Avatar answered Sep 23 '22 01:09

Sampson


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.
like image 21
Asaph Avatar answered Sep 25 '22 01:09

Asaph