Forum Moderators: phranque
As an example, lets say you have a web site where each member accesses his or her home page by typing http://www.example.com/membername, ‘membername’ being the user name of each member. It would be easy enough to create each directory and to populate it with the required template documents (like index.html), but that would consume disk space and file quantity limitations. How con one design a website so that users may access a file in a directory that does not exist physically except as information in a database?
[edited by: encyclo at 11:46 pm (utc) on Jan. 18, 2007]
[edit reason] switched to example.com [/edit]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
That's it.
I think I am looking for something more.
I think I am looking for something more.
By this I am guessing you mean you need it to differentiate between your site files and member pseudo-directories, correct?
In the above example, how this would work depends on index.php. This is one way you could approach it: since you will most likely have these members in a database, you should also record the member's "site URL:"
rec_id¦fname¦lname¦email¦site_url¦ . . . .
Then in index.php, before it looks up any site pages, first parse the path info and see if it matches on a site_url. Perl example:
http://www.example.com/MemberName
@paths = split(/\//,$ENV{PATH_INFO});
$last = pop(@paths); # Get the text after last /, "MemberName"
$select = qq¦select * from members where site_url = '$last'¦;
If the record is found, output the page. If not, index.php goes on and does whatever it does for other site files.
You will have to do something a little more complex if you offer multiple pages on this member directory, but this is one way to approach the problem.