1

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.

0

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

That's what i needed. Thx Lonesomeday.
0

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

Comments

-1

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()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.