Page 1 of 1
passing variables via address bar
Posted: Wed May 14, 2008 6:46 am
by hannnndy
hi friends
i want to pass variables using the address bar and not to use get method
for example :
http://www.parsitech.com/contact -- instead of -->
http://www.parsitech.com?id=contact
http://www.parsitech.com/about -- instead of -->
http://www.parsitech.com?id=about
i mean i want to pass variables and which are seemed there is not any variable there is not any contact directory for example but we call "
http://www.parsitech.com/contact"
is there any way?
Please help
Great thanks
Re: passing variables via address bar
Posted: Wed May 14, 2008 6:48 am
by onion2k
It's called "URL rewriting". How you do it really depends on your hosting environment. A common method is using Apache's mod_rewrite feature.
Re: passing variables via address bar
Posted: Mon May 19, 2008 3:47 am
by hannnndy
thanks for your reply
its a little un familiar to us we shoul change the apaches config or php would handle it if so how?
is there any other way?
Re: passing variables via address bar
Posted: Mon May 19, 2008 4:09 am
by Eran
you could create a simple rewrite rule to your index.php, and create your rewrite logic there. A process called 'bootstrapping' (google it)
Re: passing variables via address bar
Posted: Mon May 19, 2008 4:41 am
by hannnndy
thanks for the advice
i tried something like this
Code: Select all
RewriteEngine On
rewritecond %{http_host} ^.*
rewriteRule ^(.*) /index.php/$1
but it caused 500 nternal server error the problem is im so unfamilier to the htaccess and the coding of the it i tried it under windows server running apache : Apache 2.0 Handler and php 5.2.5
have you any real suggestion for me like the actual code or sample

Re: passing variables via address bar
Posted: Mon May 19, 2008 2:48 pm
by Eran
Try something like this in your .htaccess:
Code: Select all
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Now all requests but media, css and javascript will reach the index.php. In there you can parse them using something like:
Code: Select all
<?php
$id = $_SERVER['REQUEST_URI'];
To get the same results as you would with $_GET for your example (make sure to trim the '/' at the beginning).