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
sotre url in a variable
Moderator: General Moderators
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.
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.
Run this page:
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.
Code: Select all
<?php
phpinfo();
?>