Mobile app version of vmapp.org
Login or Join
Goswami781

: 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

@Goswami781

Posted in: #Php

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Goswami781

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kevin317

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme