How would I display dynamic content, say profile pages with the url syntax
mysite.com/users/user1
mysite.com/users/user2
mysite.com/users/user3
Without having a different page or directory for every user. I’m hoping there is a way to just have something like an index.php file in the users directory and have it display appropriate user content based on the user1, user2, user3 part of the url.
I know this is common but I’m not sure how to do it or what ever it would be called to google it?
If your running apache, you may want to look into mod_rewrite rules for your .htaccess file.
In the following example, I redirect anything that is pointing to
/users/user*to a file in the root of the site calledusers.php. You notice the([^/\.]+). This is a “catch-all” reg-ex that will allow me to create a variable for my query string (ex:?id=$1).Then in my
users.phpi can retrieve the variable as:$id = $_GET['id']This will allow me to catch and handle all user URLs with only 1 file.
Note: This is only an example. It will have to be built upon but it could be a good starting point for you