| Writing URI's differently but still accessing $ GET variables
|
ryan_b83

msg:3552986 | 4:40 pm on Jan 20, 2008 (gmt 0) | Hello, I am wondering how you can dynamically build URI's so you dont have to show the id=3 Given this example URL www.example.com/area-information.php?countryID=12&stateID=4&cityID=3892 How could you dynamically refer to the same information but displayed like this: www.example.com/area-information/United-States/Texas/Houston So basically dropping the .php from area-information.php, and converting all the variables to look like sub folders? Any ideas? Thanks, Ryan
|
venelin13

msg:3553013 | 5:44 pm on Jan 20, 2008 (gmt 0) | To access this url: www.example.com/area-information.php?countryID=12&stateID=4&cityID=3892 You may rewrite it as: www.example.com/area-information/12/4/3892 You should create an .htaccess file with this content should looks like: RewriteEngine on RewriteCond %{REQUEST_URI}!\.(gif¦jpg¦php¦pl¦swf¦css¦txt)$ RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)$ /area-information.html?countryID=$1&stateID=$2&cityID=$3 [L] (It may not work at once, this is just an example, the idea how it should be.)
|
eelixduppy

msg:3553014 | 5:47 pm on Jan 20, 2008 (gmt 0) | You could still rewrite the URI as the following:
www.example.com/area-information/United-States/Texas/Houston
However you'd have to find the IDs again for that data through your php script. If you can't do this, or it causes too much of a problem, you are probably better off going with the URI format described in the post above.
|
henry0

msg:3553029 | 6:36 pm on Jan 20, 2008 (gmt 0) | To use eelix format: If the ID exists (as it should) then it could be passed via a SESSION or by a HIDDEN value
|
|
|