Dynamic profile based website that also has hard links?
Ok, so I'm building a website that has client profiles. A web user finds these mysql profiles via a search function. The profile page is one php page that loads all the mysql data via the #id number that is passed through the address. This is all great, but my clients, based on hte business model and needs, are going to need to be able to have their profile tied to a hard address that looks nice and doesn't have variable data included in it.
Let me explain with an example. Imagine the site is called bizprofiles.com. A user searches the DB and clicks on a link from the search display. The search is just putting the ID number in the variable, so the address might resemble this:
http://www.bizprofiles.com/profile.php?id=1002937
The business isn't going to want to put an address out there like that when they want customers to visit the site, so I'm wondering how I can have a hard address that somehow still loads the profile page with the mysql data. So the biz can have an address like this:
http://www.bizprofiles.com/bizname
Keep in mind t开发者_开发知识库hat I've built this site using PHP and MYSQL. Thanks in advance for any insight you can give me!
Assign each profile a unique-name
(username, provably) and map it to the profile_id
in the database.
EDIT:
Well here's the basic idea:
You need to have .htaccess
file at the doc-root containing:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile/([a-zA-Z0-9]*)$ profile.php?user=$1 [L]
What above code does is: converts the url like http://www.bizprofiles.com/profile/bizname
to http://www.bizprofiles.com/profile.php?user=bizname
So what you need to do now is update profile.php
to display profile on the basis of this unique-name
available in $_GET["user"]
.
You need to keep so called "slug" in the database. Your table "customers" needs to store a unique name that will be used to produce a link. See Facebook, it lets you assign the name you want.
http://codex.wordpress.org/Glossary#Post_Slug
精彩评论