A file as a directory

I want to provide my users with an easy URL that connects them to a specific file.

What I've got in mind would be something like "http://www.myserver.com/their_id_number."

So, if the URL, using the format I'm envisioning, looked like this: http://www.brucegust.com/12345 then it would direct the user to the appropriate page where I'm grabbing the id number and doing the necessary coding to provide them with the info I want to communicate.

I've got over 60,000 ids, so that number of folders isn't practical, but it seems I've seen what I'm trying to do. My question is: How? How do you set up your server in such a way where you have the capacity to do what I'm attempting?

Thoughts?
brucegustPHP DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

strivoliCommented:
I would create a 2 level tree:
a. 1st level with 600 folders,
b. 2nd level with 100 folders,

The total will be 600*100=60,000 ids.
0
gr8gonzoConsultantCommented:
No problem, I've done this with a system that carried well over 2 million IDs. The solution is to use URL rewriting to look for URLs that have a specific format to them, like:

http://www.brucegust.com/#####

Then rewrite those URLs and redirect the request to a single PHP script (a quiet redirect so that the user doesn't see the URL change). That PHP script can then parse the URL and extract the ID, and present the data that is applicable for that ID.

Here's my article on using .htaccess to set up URL rewrites:
http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Apache/A_10732-The-Basics-of-htaccess-Files-and-URL-Redirection.html

I would also strongly consider using more than one ID. Have a "check" value that corresponds to the ID so that a malicious user can't just try each ID, one at a time, and extract data from your system that does not belong to them.
0
COBOLdinosaurCommented:
To extend what gr8gonzo said:

Connecting user content with an exposed id like that looks like it could be a real security problem.  You will need to have some kind of authentication to protect user information.

Cd&
0
brucegustPHP DeveloperAuthor Commented:
What I'll do is use a hex key to prevent ids from being exposed, but now, here's my question:

I'll turn on the Rewrite Engine, but then how do I configure it so it only kicks on when there's an id? My concern is that the way I have it in my head right now, any valid address after the slash is going to be processed as a rewrite and I don't want that.

So...

brucegust.com/qr/index.php?id=12345 needs to be...
brucegust.com/12345

RewriteEngine On
RewriteRule /

How do I structure my RewriteRule?
0
Julian HansenCommented:
.htaccess
AddType x-mapp-php5 .php
Options +FollowSymLinks

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ([0-9]+)$ qr/index.php?id=$1 [L,NC,QSA]

Open in new window


PHP - qr/index.php
<pre>
<?php
print_r($_REQUEST);
?>
</pre>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.