puriya
puriya

Reputation: 25

Why is trailing slash being removed from URL on a remote host?

my url's work in localhost with this code

    print "REQUEST_URI :".$_SERVER['REQUEST_URI'];print '<hr/>';
    print "site:".$site=str_replace('index.php','',$_SERVER['PHP_SELF']);print '<hr/>';
    print "REQUEST_URI:". $REQUEST_URI=str_replace($site,'',$_SERVER['REQUEST_URI']);print '<hr/>';

and resutls are

REQUEST_URI :/manogham/admin/login

site:/manogham/

REQUEST_URI:admin/login

but in server results are defirents

REQUEST_URI :/admin/login/

site:/

REQUEST_URI:adminlogin

/ are remove from url why !!!!

Upvotes: 0

Views: 137

Answers (1)

Romain B.
Romain B.

Reputation: 654

On the server

print "site:".$site=str_replace('index.php','',$_SERVER['PHP_SELF']);print '<hr/>';

is "/" as you can see on your results. $site is then "/". When you do

$REQUEST_URI=str_replace($site,'',$_SERVER['REQUEST_URI']);

you remove all $site ("/") from the REQUEST_URI That's why there is no more / displayed

Upvotes: 1

Related Questions