douyoupingji7238 2013-09-19 15: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 16: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条)

报告相同问题?

悬赏问题

  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录