2012-07-10 16:54


Say I have a user database and don't want to use get to get the id (user.php?i=234) and want to use folders and index.php(s) instead (user/234)

I can do this by creating a new folder and index.php file in that folder when the user registers. I can put an include inside the index.php file (include '/users.php') and call a function that builds the page (buildUserPage(234);)

Is this the best way to do this?

How can I get the user id based on the parent folder if 234 is the user id?

How can I check if the url of the page is index.php so I can redirect to "../"?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dos3018 dos3018 9年前

    In the .htaccess file in the user directory, place the following:

    RewriteEngine On
    RewriteRule ^(\d+)/?$ ../users.php?i=$1 [QSA,L]

    For your question directory .htaccess file, try this:

    RewriteEngine On
    RewriteRule ^(\w+)?/?(\d+)?/?$ ../question.php?l=$1&i=$2 [QSA,L]
    点赞 评论 复制链接分享