使用包含&文件夹而不是命名的php文件的index.php

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 "../"?

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]