How to Dynamically Rewrite a URL like Facebook

前端 未结 4 367
滥情空心
滥情空心 2021-01-17 03:49

I\'ve written my site using PHP and unfortunately the Artist profiles are currently like this:

website.com/profiles.php?id=xxx

That way I can GET the id and

4条回答
  •  余生分开走
    2021-01-17 04:00

    You can use a URL "slug", whereby a record has a unique name, ie:

    id     name             slug
    001    Stack Overflow   stack-overflow
    

    then you could perform a query such as:

    SELECT `fields` FROM `table` WHERE `slug`='$slug'
    

    where slug is the value from the URL.

    There are alternatives as I'm sure will be provided.

提交回复
热议问题