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..

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.