Hello everyone! I have been trying like crazy to get Apache setup in a way to redirect all URLs in a certain directory passed to a PHP file for processing. For example... http://www.example.com/api/cats/234324 http://www.example.com/api/dogs http://www.example.com/api/geese/34234 I would like all of these URLs (http://www.example.com/api/*) passed to a PHP file for processing. Also, just to make sure, once received at the PHP file, the original URL must be able to be accessed for processing. I thought I was on the right track with <LocationMatch "/api/*"> SetHandler "index.php" </LocationMatch> But that didn't seem to work at all. I have full access to the Apache server.
Hi Lpe, thanks for the quick response. The PHP file has no contents yet, I am the one that will be writing it; was that your question? I haven't decided the URL yet either, I was thinking either... http://www.example.com/api/index.php or http://www.example.com/api.php I hope those answered your questions ? If not please dumb them down for me. This is the first time I've really messed with configuring Apache.
Well, you need parameters, such as index.php?page=soandso Unless you just want everything to display index.php (but they will all look the same), that is easy to do. Cheers,
So this is what I've come up with. RewriteEngine on RewriteCond %{REQUEST_URI} ^/api/.+ RewriteRule ^/(.+)$ /api.php Works like a charm. The $_SERVER['REQUEST_URI'] and $_SERVER['QUERY_STRING'] PHP vars are both still from the original request, so I can process them easily.
cool, by the way you should be able to take out that first part if you wanted to. RewriteRule ^api/(.+) api.php [L] But it doesn't matter. Cheers,