I am creating a web application that is js client-side heavy, data is being sent to chunks from the server.
I am trying to implement a solution for a friendly URL solution that accepts a URL:
http://exmample.com/find/SomethingHere-or-there
This means that a number of variables are not displayed. Thus, it may end up processing as follows:
http://exmample.com/index.php?loc=London&type=2&priceCat=10-15
I get the values ββby passing a friendly URL as a parameter, and then return the full URL.
My initial implementation used the mod_rewrite rule to forward to a script that retrieves the friendly url, requests db for the corresponding friendly url and returns the full url with all the parameters it maps to, builds a url string with that then go to the web address, which then fetches Options on the front side of the web application.
However, I lose the friendly URL when I use the php header ("Location: http://example.com ") so that they see the full URL with parameters. This is one of the secondary requirements that I am trying to fulfill.
Then I thought that since my js web application is heavy, should I try to display the page and then add the parameters from db to my web application? Is this the best way or is there another trick to achieve this that I don't know about?
The use of the js client side is not allowed.
some code is attached to describe my internal implementation:
//get the friendly url as a parameter $goto = explode('=',$_SERVER['QUERY_STRING']); //$goto[1] = SomethingHere-or-there //build the friendly URL string $forwardingURL = 'Location:http://'.$_SERVER['HTTP_HOST'].'/'.getForwardedURL($goto[1]); //will be http://exmample.com/index.php?loc=London&type=2&priceCat=10-15 header($forwardingURL); //function that returns the full url param string from the friendly url function getForwardedURL($friendlyURL){ $friendlyURL = mysql_escape_string($friendlyURL); $query = " SELECT url FROM FriendlyURLmapping WHERE friendly_url = \"$friendlyURL\""; $resultP = mysql_query($query) //the full parametised URL will be in $row $row = mysql_fetch_array($resultP, MYSQL_ASSOC); return $row["url"]; }