Filtering / Dispatch for PHP?

This is a discussion on Filtering / Dispatch for PHP? within the PHP Language forums, part of the PHP Programming Forums category; Hey all, I'm having a bear of a time locating any information on how PHP might handle URL filtering ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008
Mark Space
 
Posts: n/a
Default Filtering / Dispatch for PHP?

Hey all,

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.

www.example.com/this/is/a/long/url

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)
long_url_path.php.

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. ;)
Reply With Quote
  #2 (permalink)  
Old 04-12-2008
Piotr
 
Posts: n/a
Default Re: Filtering / Dispatch for PHP?

Mark Space wrote:
> Hey all,
>
> 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.
>
> www.example.com/this/is/a/long/url
>
> 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)
> long_url_path.php.
>
> 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. ;)


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

FM:
http://httpd.apache.org/docs/2.0/howto/htaccess.html

short version:
..htaccess file contents
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

best regards
Piotr Nastaly
Reply With Quote
  #3 (permalink)  
Old 04-13-2008
Mark Space
 
Posts: n/a
Default Re: Filtering / Dispatch for PHP?

Piotr wrote:

> 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 files.
>
> FM:
> http://httpd.apache.org/docs/2.0/howto/htaccess.html



Succinctly answered. Thank you!
Reply With Quote
  #4 (permalink)  
Old 04-13-2008
Piotr
 
Posts: n/a
Default Re: Filtering / Dispatch for PHP?

Mark Space wrote:
> Piotr wrote:
>
>> 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 files.
>>
>> FM:
>> http://httpd.apache.org/docs/2.0/howto/htaccess.html

>
>
> Succinctly answered. Thank you!

On the second though, I think I gave you bad link.. :
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

but you seem to be smart enough to find it yourself by this time

best regards
Piotr Nastaly
Reply With Quote
  #5 (permalink)  
Old 04-14-2008
Mark Space
 
Posts: n/a
Default Re: Filtering / Dispatch for PHP?

Piotr wrote:
> Mark Space wrote:
>> Piotr wrote:
>>
>>> 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 files.
>>>
>>> FM:
>>> http://httpd.apache.org/docs/2.0/howto/htaccess.html

>>
>> Succinctly answered. Thank you!

> On the second though, I think I gave you bad link.. :
> http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
>
> but you seem to be smart enough to find it yourself by this time
>
> best regards
> Piotr Nastaly


Your first link was closer to what I really needed, but mod_rewrite is
interesting and useful too. I'm still learning how to deal with Apache
directly rather than through some sort of CMS. Thanks again.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:51 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0