Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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:

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

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

share|improve this question

This is fairly easily done with mod_rewrite, Wordpress uses this quite often

RewriteBase /foo/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /somedir/foo/script.php [L]
share|improve this answer
Thanks. But where do I place these directives? – scrapdog Jan 26 '11 at 17:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.