1

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

For example, if someone requests:

www.example.com/foo

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

Andres
  • 111
  • 2

1 Answers1

2

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

27nov
  • 96
  • 2
  • 1
    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 04 '12 at 01:33