Hopefully I'm able to explain this correctly...

I've got a internet search engine script that runs off PHP and uses API's from various places. I must have the ability to generate query results ($q) in line with the URL.

e.g. If your user would go to domain.com/stackoverflow I'd like the website to instantly generate a question that runs searching for "stackoverflow". i.e. $q = stackoverflow.

I guess this is actually the complete opposite of the header function in PHP, where rather than putting information in to the URL bar I wish to take information out.

I understand there might be some editing to .htaccess to make this happen, but is it feasible? It might also mean having the ability to handle conflicts with whatever might already sit on the website, e.g. I will have to define that domain.com/login is reserved and also to not operate a query explore that, etc.

This is accomplished with the $_GET array.

Imagine here's your url: http://world wide web.website.com/?foo=bar then $_GET['foo'] is going to be bar.

If you wish to make a move like domain.com/stackoverflow you will have to use htaccess to rewrite that hyperlink to something similar to domain.com/?domain=stackoverflow and you can can get on through $_GET['domain'].

Basically understood well, you could utilize the function parse_url(). Here you will find the documentation.

You will find a number of ways to do what you would like.

  1. You need to use .htaccess to ModRewrite it in ways to ensure that example.com/?q=whatver will end up example.com/whatever, after which use PHP's $_GET superglobal. to find the information normally.
  2. You could utilize PHP's parse_url() function, obtain the path and employ it ($parsed_url['path']).

Best of luck :)