Saturday, January 28, 2017

Directing requests on Apache, and transforming how the request URI is seen

How can I configure Apache to direct requests for particular URL on server to a particular directory, while at the same time transforming how that URL is seen by the script that processes it?



Say I have a php script in the following directory:




/somedir/foo/script.php



I would like all incoming HTTP requests to http://server/foo/* to be processed by /somedir/foo/script.php. However, I would also like the script to know what the remainder of the URI is in the REQUEST_URI variable.
(The * part of the URL is opaque information that is only meaningful to the script, and could be anything)



For example:



http://example.com/foo/



will be handled by /somedir/foo/script.php, and the script will see the REQUEST_URI as simply "/" and



http://example.com/foo/the/quick/brown/fox.html


will also be handled by /somedir/foo/script.php, while REQUEST_URI will be seen as "/the/quick/brown/fox.html"



How do I configure Apache to behave this way?



(Note that this is strictly an Apache question; I do not want to alter the script in any way.)

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...