How can I access a variable GET variable from PHP if the URL is like this:
http://example.com/somehash
I obviously know how to do it when there is something like this:
http://example.com/f.php?h=somehash
Here I would just take $_GET[“h”], but i don’t know how to do it for the first case…
The answer is that you can’t. At least not without some additional web server configuration. Typically to achieve “clean URL’s” like this in PHP, there is a URL rewrite that is performed in the webserver (
mod_rewritefor example on Apache). What this does is silently redirect requests forto be handled by a script at
This allows PHP to populate
$_GETas it normally would, while still showing a clean URL in the browser.You can search StackOverflow or Google for any number of examples of how to do URL rewrite for clean URL’s.