Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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
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 4 '12 at 1:33
add comment

Your Answer

 
discard

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.