Apache Virtual Path

Say there is a certain path I wish to always load the same page. So if they go to somesite.com/a/b/c, it always goes to myscript.php and fed a/b/c as a server variable.

I'm fairly sure this is possible but cannot remember the term it's called, and so cannot find it in web searches or documentation. Any hints please?

You are looking for mod_rewrite and the rewrite engine.

You probably need something like (from memory):

RewriteRule (.*) myscript.php?id=$1

I'm not so sure. I don't think the original name would be preserved, and I need that.

Hm, I think, it does. I put a script myscript.php in the document root:

<?php
    echo 'myscript.php running with id = ' . $_GET['id'];
?>

In the apache config I added:

<Directory /var/www/html>
     RewriteEngine On
     RewriteCond %{REQUEST_URI} !^/myscript.php.*
     RewriteRule (.*) myscript.php?id=$1 [L]
</Directory>

When you enter the URL http://servername/a/b/c in the browser, the output looks like:

myscript.php running with id = a/b/c

[edit] Actually, this does not work.

This changes the URL the client goes to, it redirects and changes the address bar. I do not want that. I just want anything beneath a certain folder to all call the same script.

In my test environment (CentOS 6.4, Apache 2.2, PHP 5.3.3) it does not change the URL in the address bar of the browser. And in my opinion, this is expected, because it is not a redirect but a rewrite within the webserver.

If it does for you, there must be some other difference between our environments.

I'm not sure why some rewrite rules redirect and some don't, but I fiddled until I got it working. Thank you.

You are welcome, glad I could help.