Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Filtering / Dispatch for PHP?
- Mark Space
April 12, 2008, 7:52 pm
rate this thread
I'm having a bear of a time locating any information on how PHP might
handle URL filtering and dispatching.
For example, let's say I have a web site where I have one main PHP
script that examines all URLs and sends the request to an appropriate
other script to handle.
I want all paths at example.com to be handled by one PHP script. That
script should receive the request above, and any other. Then that
script looks at the path information, and decides that long_url_path.php
is the script to handle it, and dispatches (or just calls)
Note I want a server side dispatch, not client side redirect. I don't
want to use HTTP status 300's please.
Buried is my question is concerns about security. How do I stop users
from calling scripts directly when they should have no access to that
script? I'd like to hide the path information, as well as prevent them
from ever even guessing the path (by typing random strings in the path
portion of the URL for example, ie. a brute force attack).
Any pointers? I'll take an "RTFM" if it's accompanied by a link to the
appropriate section of the FM. ;)
Re: Filtering / Dispatch for PHP?
There is no such feature in PHP alone, you need to force your webserver
to do that, if you use Apache, the right way is to use mod_rewrite and
.htaccess file contents
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php