Jump to content

"example.com/user1" instead of "example.com/index.php?id=1"


hassank1

Recommended Posts

Hi

 

I am working on a website where the change of the id (index.php?id=x) will lead to a different profile information based on the 'x' value

 

till now, things are very simple, however, I want to change that so instead of  example.com/index.php?id=x , I want to write example.com/userX

 

similiar to when facebook create usernames instead of just a profile id

 

I know that I can create directories each time dynamically (like user1,user2,etc... all directories)

 

but isn't there another method where the links are virtual and not real directories ? so I can get the link and compare it with a database, instead of each time creating a directory then placing an index file inside of it that will redirect to the specific id ?

 

ex : (db table)

 

id  name

1    user1

2  user2

etc..

Link to comment
Share on other sites

Yup, it's called the Apache "mod_rewrite" module. It allows you to specify regular expression based patterns that the server will check for on requests. I dare say if you search for "mod rewrite cheat sheet" or something, you'll find what you're after.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.