5

我正在创建一个购物门户,每个客户都将在其中发布他们的产品,一旦付款,我们将为该客户提供单独的用户名和密码。因此,我需要为每个客户分别创建一个 URL 链接,以便显示该特定客户的产品。

例如,如果我创建一个单独的帐户,就像 Facebook 一样,我的页面将变为 ( https://www.facebook.com/dinesh.darkknight ),其中显示了我自己的详细信息或帖子。像这样,我需要为我的网站 (www.seloncart.com/customername) 中的每个客户提供一个单独的页面。一旦我给了那个客户的名字,它应该只显示那个客户发布的产品。

4

2 回答 2

2
  1. Configure your server to run everything through the script (e.g., in Apache, ScriptAlias / /hosts/example.com/htdocs/yourApplication.php)
  2. Look at $_SERVER['PATH_INFO'] to determine what the user name is (if there is one).
  3. Use that information to decide if you are going to show a "list of products page" or something else
  4. Search your database for the appropriate data

You'll probably find that a lot of MVC frameworks help rather a lot with steps 2 and 3.

于 2013-05-23T06:29:08.187 回答
1

If you use a framework like CodeIgniter, your URL works like this:

www.url.com/Controller/Function/Argument/Argument...

So in the code you might have:

class Account extends CI_Controller{
    public function info($username){
        echo getInfoPage($username);
    }
}

Which would translate to:

www.url.com/account/info/dinesh

You can also look into changing your .htaccess file.

于 2013-05-23T06:28:58.780 回答