Is it possible to clean up the address line on the browser, so that it does not reveal the querystrings and variables that are passed from page to page?
Thanks!
Fernando
How can we clean up the address line?
Moderator: General Moderators
Cleaning up a URL
Yes you can easily clean up a url using PHP's inbuilt functions, i.e. explode.
Consider the following for example.
You have a file called articles.php which when given two vars, section and page, will display a particular story fetched from your database. (E.G. articles.php?section=php+is+cool&page=1234), But if it is only given the section variable, then it should display a list of articles under that section.
Yes you can use MOD_REWRITE, or Javascript, or you can use php. The way I got around it was to rename articles.php to just articles. Added a .htaccess and added a ForceType application/x-httpd-php directive for my file. This would allow my url to look like this :
/articles/section+name/1234.html
Heres a sample of the code. I am afriad its not great as I wrote this ages ago when I still did not know much about PHP>
Code: Select all
$var_array = explode("/", $PATH_INFO);You have a file called articles.php which when given two vars, section and page, will display a particular story fetched from your database. (E.G. articles.php?section=php+is+cool&page=1234), But if it is only given the section variable, then it should display a list of articles under that section.
Yes you can use MOD_REWRITE, or Javascript, or you can use php. The way I got around it was to rename articles.php to just articles. Added a .htaccess and added a ForceType application/x-httpd-php directive for my file. This would allow my url to look like this :
/articles/section+name/1234.html
Heres a sample of the code. I am afriad its not great as I wrote this ages ago when I still did not know much about PHP>
Code: Select all
<?php
$var_array = explode("/", $PATH_INFO);
$file=$var_arrayї0];
$section=$var_arrayї1];
check_section($section);
$articleid=$var_arrayї2];
if($section && $articleid)
{
// Ok a section has been selected. List all the articles for this section.
$query = mysql_query("SELECT * from articles where articleid='$articleid'" and section='$section') or die ("could not execute");
}
else .....
?>