Webmasters Stack Exchange is a question and answer site for pro webmasters. 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

I want to create a script that pass every folder requested in a website as a parameter.

For example, if someone requests:


...that will be redirected to the main index.php and passed as a parameter, getting the same result when requesting www.example.com/index.php?foo

Please note that the folder requested will be random so i can't predict the folder and put a php script there.

Should i handle all the 404 requests through HTACCESS? Or there's a fancier solution?

share|improve this question

Sorry but "www.example.com/index.php?foo" foo is an argument without value, so useless. But if you want it "www.example.com/index.php?parameter=foo" You have to enable rewrite_mod on apache web server and use Url Rewriting in a .htaccess file.that an example which works:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-z]+)$   index.php?id=$1 [L]

So example.com/abcd -> example.com/index.php?id=abcd

share|improve this answer
Actually 'foo' is not useless in the OP's example. In PHP at least, the parameter is available; but your solution of parameter=foo is better. – DisgruntledGoat May 4 '12 at 1:33

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.