Page 1 of 1

sotre url in a variable

Posted: Sat Jan 10, 2004 6:06 am
by raj74
hi,

i am a newbie, how can i store the current url in a variable.
OR
redirect user based on virtual directory for example if user types http://localhost/TM then he should redirect to tm.php

If user types http://localhost/king then he should go to king.php

I also tried the server variable like $PHP_SELF nothing is working.any help

thanks in advance
raj

Posted: Sat Jan 10, 2004 6:15 am
by markl999
Well, the current uri is already in a variable, $_SERVER['PHP_SELF']. As for the second bit, you can force 'foo' to be parsed as a PHP file using an apache ForceType Directive (google for it ;) ). It just means you name you files _without_ the .php extension.
Alternatively you could use a mod_rewrite to rewrite foo to foo.php but that's more trouble that it's worth and isn't really an option.

Posted: Sat Jan 10, 2004 6:16 am
by JAM
Run this page:

Code: Select all

<?php
phpinfo();
?>
Check the bottom of the page generated (the $_SERVER[*]) for more ideas on what you might be able to use. They are listed as _SERVER but in a php script, add the $ before them.