Welcome Guest, Not a member yet? Register   Sign In
Warning in core/URI.php with rewrite
#1

[eluser]Unknown[/eluser]
I've followed the instructions for rewriting urls in my .conf (not .htaccess) file, and I'm generating a warning now:

Code:
A PHP Error was encountered
Severity: Warning
Message: strpos() [function.strpos]: Empty delimiter
Filename: core/URI.php
Line Number: 149
A PHP Error was encountered
Severity: Warning
Message: strpos() [function.strpos]: Empty delimiter
Filename: core/URI.php
Line Number: 153

I've fixed it by checking that $_SERVER['SCRIPT_NAME'] is not blank before calling that

Code:
if (!empty($_SERVER['SCRIPT_NAME']))
        if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)

I think this is a bug, or possibly a configuration error, though I've followed the instructions at

http://codeigniter.com/wiki/mod_rewrite/

Tac
#2

[eluser]Unknown[/eluser]
I believe it is a bug:

From system/core/URI.php:149-156
Code:
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
{
    $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
}
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
{
    $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
}

This should really be checking whether $_SERVER['SCRIPT_NAME'] has any contents like this (and thus is safe to pass as the second parameter to strpos):

Code:
if($_SERVER['SCRIPT_NAME'] != '')
{
    if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
    {
        $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
    }
    elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
    {
        $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
    }
}

Nik.

Edit: I've posted this up on the bug tracker now Smile

Edit Edit: Gah, those smilies are ugly - Deploying alternative smiley: ^_^




Theme © iAndrew 2016 - Forum software by © MyBB