Page 1 of 1

How can we clean up the address line?

Posted: Sat Nov 30, 2002 2:54 am
by Pavon
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

Posted: Sat Nov 30, 2002 3:08 am
by MeOnTheW3
If you can not use POST methods, I believe there is a javascript method to actually change the browser.location.???? without actully changing the document.url, which would not be the desired result.

Good luck, I would be interested in knowing what your final decision was.

Cleaning up a URL

Posted: Sat Nov 30, 2002 8:33 am
by dezel
Yes you can easily clean up a url using PHP's inbuilt functions, i.e. explode.

Code: Select all

$var_array = explode("/", $PATH_INFO);
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

<?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 .....
?>