Connecting Tech Pros Worldwide Forums | Help | Site Map

Does PHP have anything like Java/JSP "filters" or Zope's acquisition?

Soefara
Guest
 
Posts: n/a
#1: Jul 17 '05
What I'd like to have a request to, say, http://www.mydomain.com/Aaaa/Bbbb/Cccc

be handled by http://www.mydomain.com/Aaaa/index.php

but with the "Bbbb" and "Cccc" stored in a request variable or attribute.
This becomes very very useful when building multi-lingual websites.

This can be done in JSP/servlets using 'filters' and it is
provided in Zope through 'acquisition'.

Is there any way of making this happen with PHP ?

Thank you very much,

Soefara

Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Does PHP have anything like Java/JSP "filters" or Zope's acquisition?


Soefara wrote:[color=blue]
> What I'd like to have a request to, say, http://www.mydomain.com/Aaaa/Bbbb/Cccc
>
> be handled by http://www.mydomain.com/Aaaa/index.php
>
> but with the "Bbbb" and "Cccc" stored in a request variable or attribute.
> This becomes very very useful when building multi-lingual websites.[/color]
[color=blue]
> Is there any way of making this happen with PHP ?[/color]

I do that with Apache's ErrorDocument

0. Be sure Apache AllowOverride is set to include FileInfo
1. Create Directory "Aaaa"
2. Create an .htaccess there with
ErrorDocument 404 /Aaaa/index.php
3. Create /Aaaa/index.php as (for example):
<?php
echo $_SERVER['REQUEST_URI'];
?>
4. Go to http://www.mydomain.com/Aaaa/Bbbb/Cccc

5. and see the resulting page:
/Aaaa/Bbbb/Cccc

HTH
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Soefara
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Does PHP have anything like Java/JSP "filters" or Zope's acquisition?


Wow, that's a really interesting hack, Pedro :)

I've never seen people actually use .htaccess and ErrorDocument
to filter requests like that. Thanks for sharing this - it looks
like it will do what I want :)

Soefara

[color=blue]
> I do that with Apache's ErrorDocument
>
> 0. Be sure Apache AllowOverride is set to include FileInfo
> 1. Create Directory "Aaaa"
> 2. Create an .htaccess there with
> ErrorDocument 404 /Aaaa/index.php
> 3. Create /Aaaa/index.php as (for example):
> <?php
> echo $_SERVER['REQUEST_URI'];
> ?>
> 4. Go to http://www.mydomain.com/Aaaa/Bbbb/Cccc
>
> 5. and see the resulting page:
> /Aaaa/Bbbb/Cccc
>
> HTH[/color]
Henk Verhoeven
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Does PHP have anything like Java/JSP "filters" or Zope's acquisition?


Hi Soefara,

We also use a .htaccess trick to get the requests to our index.php script:

RewriteEngine on
RewriteRule ^index_php/(.*) index.php?$1

(this requires your internet provider to make a setting to allow url
rewriting).

But down from index php we use request handlers, which are objects, much
like servlets, only we create a new request handler for each request (In
Java, servlets may be reused, of even handle multiple requests at the
same time). In combination with request forwarding request handlers can
act like filters: For example, this is how our website's
LicenseAgreementAction reacts to accepting the the license agreement
before downloading:

function doAgreed()
{
$this->useClass('Menu', 'beheer');
$forwardData = array(
'pntType' => 'Menu',
'id' => Menu::getDownloadMenuId(),
'download' => $this->requestData['download'],
'pntHandler' => 'WebStartDownloadPage'
);
$this->forwardRequest($forwardData, 'agreed');
}

This creates an instance of the class WebStartDownloadPage and forwards
the requestData. The page then produces the output that starts the
download. As you can see it creates new requestData for forwarding
(makes the page show the download menu), only 'download' is copied from
the original requestData.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.


Soefara wrote:
[color=blue]
> Wow, that's a really interesting hack, Pedro :)
>
> I've never seen people actually use .htaccess and ErrorDocument
> to filter requests like that. Thanks for sharing this - it looks
> like it will do what I want :)
>
> Soefara
>
>
>[color=green]
>>I do that with Apache's ErrorDocument
>>
>>0. Be sure Apache AllowOverride is set to include FileInfo
>>1. Create Directory "Aaaa"
>>2. Create an .htaccess there with
>> ErrorDocument 404 /Aaaa/index.php
>>3. Create /Aaaa/index.php as (for example):
>> <?php
>> echo $_SERVER['REQUEST_URI'];
>> ?>
>>4. Go to http://www.mydomain.com/Aaaa/Bbbb/Cccc
>>
>>5. and see the resulting page:
>> /Aaaa/Bbbb/Cccc
>>
>>HTH[/color][/color]

Closed Thread