Change URL Address make short in PHP

2019-01-25 16:29发布

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

4条回答
走好不送
2楼-- · 2019-01-25 16:57

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/

查看更多
一纸荒年 Trace。
5楼-- · 2019-01-25 17:13

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.
查看更多
登录 后发表回答