Welcome Guest, Not a member yet? Register   Sign In
Router.php & "/"
#1

[eluser]SplashCreativity[/eluser]
Hey

I'm getting some errors whenever I have a trailing slash on my url.

http://mysite.com/index.php is fine
http://mysite.com/index.php/ gives me errors

Same goes without the index.php, though if I do

http://mysite.com/controller/

It's fine, the routing works fine.

Here are the errors:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: libraries/Router.php

Line Number: 190
A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: libraries/Router.php

Line Number: 196
A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: libraries/Router.php

Line Number: 199
#2

[eluser]louis w[/eluser]
Strange, this should not be a problem.

Have you made any changes to the routers config?

Are you on a Windows server?
#3

[eluser]SplashCreativity[/eluser]
I haven't made any changes nope, also it is hosted on a normal dreamhost server (linux).
The problem doesn't occur if I remove the .htaccess
#4

[eluser]MCrittenden[/eluser]
What does your .htaccess look like?
#5

[eluser]SplashCreativity[/eluser]
I have removed it for the time being, something strange was happening. On dreamhost, eventually the .htaccess file would disappear (though it would still be taking effect) and then my css folder wasn't working (possibly because it saw http://mysite.com/css/ as http://mysite.com/index.php/css/) so I tried to add css| after images| (using the example htaccess file from the userguide)... this broke the htaccess.

Ultimately I think I will place my CSS in the images folder, or root directory.

If somebody could supply me with a htaccess which will work with 1.6.2 I would be most grateful.

Regards
Stephen
#6

[eluser]MCrittenden[/eluser]
The wiki has one that has worked fine for me, although I just noticed that there is a separate wiki page for Dreamhost users that you might want to try. Good luck!
#7

[eluser]louis w[/eluser]
If you have:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

In your htaccess you should not have to add directories to exclude. I would hate to have to maintain a list like that.

Are you sure the .htacess is dissapearing and not just being hidden. A lot of ftp clients will not show files which start with a period.
#8

[eluser]SplashCreativity[/eluser]
Thanks for the quick replies, sorry I am late checking them.
I didn't notice dreamhost had a seperate htaccess setup.

I shall try that now

Also I am using FileZilla.

I don't have the above rewriteconds in my htaccess louis w though I will see how the wiki treats me, if it goes well I shall let you know
#9

[eluser]Unknown[/eluser]
I don't know if this has been solve or not, but I'll go ahead and post my solution for the same problem I had with my server.

File: Router.php
Method: _set_routing()
Line: 94 (without modification)
Code:
//Look for this:

        // Fetch the complete URI string
        $this->uri->_fetch_uri_string();
    
        // Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
        if ($this->uri->uri_string == '')
        {
          ...

For some reason $this->uri->uri_string yields "/" using var_dump().
So the solution was pretty simple in my case.
All that needs to be done is do a check and empty it out.
Code:
// Fetch the complete URI string
        $this->uri->_fetch_uri_string();

        /* ***************************************
         * Solution
         * ***************************************
         */
        if ($this->uri->uri_string === '/') {
            $this->uri->uri_string = '';
        }
        
        // Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
        if ($this->uri->uri_string == '')
        {
                  ...

By looking at that code, I advice not be tempted to do something I was going to do ... like this:
Code:
if ($this->uri->uri_string == '' || $this->uri->uri_string == '/')

The "if" condition really wants to make sure that ...
Code:
$this->uri->uri_string = ''
... in order to load the default controller. So all I did is play safe and just clear the value.

I hope this helps the OP or anyone that may have this problem in the future.

Note that I'm with Mediatemple with Grid Server (gs)
#10

[eluser]SplashCreativity[/eluser]
I've read your reply and I have to say it makes perfect sense, I can't try it right now but I definately will later on this evening, I'll let you know how it works out.

Best Regards
Stephen




Theme © iAndrew 2016 - Forum software by © MyBB