: Folder as parameter in PHP 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
I want to create a script that pass every folder requested in a website as a parameter.
For example, if someone requests:
example.com/foo
...that will be redirected to the main index.php and passed as a parameter, getting the same result when requesting 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?
More posts by @Goswami781
1 Comments
Sorted by latest first Latest Oldest Best
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= [L]
So example.com/abcd -> example.com/index.php?id=abcd
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.