For my website to function properly my home page (index.php) needs to have url parameters on the end.
Once the user goes from another page to index.php they are added via the navbar buttons.
Is there a way to add the url parameters to the initially displayed index.php such as someone arriving from google search?

    Google search only lists what it has found on your domain.
    It will follow links it can find via the navigation and if there is text on the page it will index it - so it will already have any required URL parameters.
    You should ensure the plain www.yourdomain.com/index.php displays a home page.

      After doing a bit of research I found a solution -
      the http_build_query function which takes an array of variables and builds a nice URL encoded string which you can append to a url.

               [code=php]        $myvariable = "myvariable";
      	$title = "Welcome to Health";		
      
      	$fields = array('myvariable' => $myvariable,
      					'title' => $title);
      
      	$url = "http://mywebsite/index.php?" . http_build_query($fields, '', "&");
      
      	header("Location: $url");

      [/code]
      Tested locally gives

      localhost/index.php?myvariable=myvariable&title=Welcome+to+Health

        Write a Reply...