Reputation: 417
Here is the URL :
http://mytesturl.com/index.php/myvalue
I would like to be able to pull "mydata" from the URL above without parsing or using regular expressions.
I am wondering if there is a built-in way to get the data "mydata"
.
Also do we have a name for this structure?
I know if I have this http://mytesturl.com/index.php?t=myvalue
This is a query sting and I can easily pull the value of t
in any language.
Upvotes: 1
Views: 93
Reputation: 1213
Actually i would do this either in a .htaccess file if you don't have access to your webserver (ie apache), and if you do change it in your virtual host file, make sure you allowrewrite All and have the a2 module rewrite on (a2enmod rewrite)
Then you can do something like this :
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Then all stuff after the fqdn will become available trhough _GET
Upvotes: 0
Reputation: 9142
It looks like there's a PHP router going on here. Try doing a var_dump($_SERVER)
and look for your value, it may be in $_SERVER['QUERY_STRING']
or $_SERVER['PATH_INFO']
. Otherwise, you can also try parse_url()
Upvotes: -1
Reputation: 237827
In PHP, you can get this with the PATH_INFO
server variable. This provides
any client-provided pathname information trailing the actual script filename but preceding the query string (source)
In this case, $_SERVER['PATH_INFO']
will be /myvalue
.
Upvotes: 2