Closed GoogleCodeExporter closed 9 years ago
I've figured it out I think. The problem seems to be that CodeIgniter's URI
class
parses the URI - http://<yoursite.com>/sweetcron/ - and returns /sweetcron/ as
a
'segment', when it really ought to ignore that bit since it's part of the base
site
URL.
So what happens is that in Router::_parse_routes (system/libraries/Router.php)
the
following call gets made:
$this->_set_request($segments);
$segments is an Array([0] => 'sweetcron'). Thus, the
Router::_validate_request()
call later on fails since there is no file: system\application\controllers
\sweetcron.php (or something like that!)
Original comment by little...@gmail.com
on 28 Aug 2008 at 7:27
My quick and dirty fix:
In system/libraries/Router.php find Router::_parse_routes method and replace
the
following:
$this->_set_request($this->uri->segments);
with:
// count no. of slashes in base_url_path as n -> disregard (n-1)
// uri segments
$config = & get_config();
$base_url_parsed_array = parse_url($config['base_url']);
$base_url_path = $base_url_parsed_array['path'];
$numSlashes = substr_count($base_url_path, '/');
$segments = array_slice($this->uri->segments,$numSlashes-1);
// If we got this far it means we didn't encounter a
// matching route so we'll set the site default route
$this->_set_request($segments);
Original comment by little...@gmail.com
on 28 Aug 2008 at 7:29
Can you attach your revised Router.php? I'm having the same problem hosting it
in a sub-folder.
Original comment by cineve...@gmail.com
on 28 Aug 2008 at 7:52
I've attached my Router.php.
Original comment by little...@gmail.com
on 28 Aug 2008 at 8:19
Attachments:
Thanks, still getting the same 404 error though.
Original comment by cineve...@gmail.com
on 28 Aug 2008 at 8:48
Make sure you've got the configuration and .htaccess setup correctly as
explained in
the installation guide (there's an extra bit at the end for subfolder
installations).
My .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /sweetcron/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
My config.php:
$config['base_url'] = "http://<domain.com>/sweetcron/";
Original comment by little...@gmail.com
on 28 Aug 2008 at 8:56
you do not need to hack around in the core. everything is handled via config
and .htaccess.
CI recognises the correct order of uri segments as long as you set the correct
base url and your htaccess is
correct.
Original comment by yongf...@gmail.com
on 29 Aug 2008 at 2:17
Are my .htaccess and config.php settings above correct? That's what I had when
I
first ran it and it didn't work. The 404 error page I got was being generated
by the
show_404() method.
Original comment by little...@gmail.com
on 29 Aug 2008 at 6:16
Original issue reported on code.google.com by
little...@gmail.com
on 28 Aug 2008 at 7:24