douyoupingji7238 2013-09-19 07:58
浏览 69
已采纳

为什么.htaccess中来自toro php路由器的配置不起作用?

the Toro docs show:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]

but i tryed many times and different ways, but, doesn't work... After a lot of searching i found this (source):

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php?$1 [L]

Just need to change in RewriteRule ^(.*)$ /index.php/$1 [L] the / to ? , to get this RewriteRule ^(.*)$ /index.php?$1 [L]

Someone know why the original doesn't work, or have a different aproach for this?

MORE INFO Host: php5.4 fastcgi, shared host, company Dreamhost. Just accept SCRIPT_NAME instead of PATH_INFO

the Toro code that handle it is:

$path_info = '/';
        if (!empty($_SERVER['PATH_INFO'])) {
            $path_info = $_SERVER['PATH_INFO'];
        }
        else if (!empty($_SERVER['ORIG_PATH_INFO']) && $_SERVER['ORIG_PATH_INFO'] !== '/index.php') {
            $path_info = $_SERVER['ORIG_PATH_INFO'];
        }
        else {
            if (!empty($_SERVER['REQUEST_URI'])) {
         $path_info = (strpos($_SERVER['REQUEST_URI'], '?') > 0) ? strstr($_SERVER['REQUEST_URI'], '?', true) : $_SERVER['REQUEST_URI'];
                }
        }

展开全部

  • 写回答

2条回答 默认 最新

  • dongtiao0657 2013-09-19 08:10
    关注

    You probably are running on a server that doesn't support the PATH_INFO style of cgi. This is where the script itself is /index.php and the "PATH_INFO" is the pathname that comes after it. Take a look at the AcceptPathInfo documentation:

    This directive controls whether requests that contain trailing pathname information that follows an actual filename (or non-existent file in an existing directory) will be accepted or rejected. The trailing pathname information can be made available to scripts in the PATH_INFO environment variable.

    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.

    The primary purpose of the AcceptPathInfo directive is to allow you to override the handler's choice of accepting or rejecting PATH_INFO. This override is required, for example, when you use a filter, such as INCLUDES, to generate content based on PATH_INFO. The core handler would usually reject the request, so you can use the following configuration to enable such a script:

    <Files "mypaths.shtml">
    Options +Includes
    SetOutputFilter INCLUDES
    AcceptPathInfo On
    </Files> 
    

    So you could try turning AcceptPathInfo to "On" and see if that helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部