What happens when i put a slash (/) after a .php url?

后端 未结 2 1786
一生所求
一生所求 2021-01-02 13:51

I have a simple question, but could not find the answer anywhere

say I have a site \"mysite.com\". I can access the index page by either typing \"mysite.com\" or \"

2条回答
  •  萌比男神i
    2021-01-02 14:30

    This is due to your Apache environmental variable called PATH_INFO.

    PATH_INFO

    Actually, PATH_INFO is related to the Apache Web Server serving PHP pages and not PHP per-say.

    PATH_INFO is an environment variable set by Apache when the AcceptPathInfo directive is turned on. It will contain trailing pathname information that follows an actual filename (or non-existent file in an existing directory) will be accepted or rejected. Environment variables are then passed on to the Apache/CGI module in charge of rendering the page.

    The variable is accessible in PHP using $_SERVER['PATH_INFO'].

    For example, assume the location /test/ points to a directory that contains only the single file here.html. Then requests for /test/here.html/more and /test/nothere.html/more both collect /more as PATH_INFO.

    This answer is copied from Andrew Moore Link to original answer

提交回复
热议问题