Welcome Guest, Not a member yet? Register   Sign In
Major weirdness, sudden 404 with no changes.
#1

[eluser]awpti[/eluser]
http://www.onlytechnews.com/

Page works fine.

http://www.onlytechnews.com/devblog/2

^^ Was working last night. I get up and it's kicking back a 404. No code changes have been made, all files are there. Hell, it was working this morning while I was in the middle of writing a new post (which hasn't been finished now!)

routes.php
Code:
$route['default_controller']    = 'otn_front';
$route['devblog/:num']          = 'otn_front/devblog';
$route['devblog']               = 'otn_front/devblog';
$route['scaffolding_trigger']   = "";

config.php
Code:
$config['base_url']     = "http://www.onlytechnews.com/";

$config['index_page'] = "";

$config['uri_protocol'] = "AUTO";

$config['url_suffix'] = "";

$config['language']     = "english";

$config['charset'] = "UTF-8";

$config['enable_hooks'] = FALSE;

$config['subclass_prefix'] = 'MY_';

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';

$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';

$config['log_threshold'] = 1;

$config['log_path'] = '';

$config['log_date_format'] = 'Y-m-d H:i:s';

$config['cache_path'] = '';

$config['encryption_key'] = "***********";

$config['sess_cookie_name']             = 'otn_web';
$config['sess_expiration']              = 7200;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']              = 'ci_sessions';
$config['sess_match_ip']                = FALSE;
$config['sess_match_useragent'] = TRUE;

$config['cookie_prefix']        = "";
$config['cookie_domain']        = "";
$config['cookie_path']          = "/";

$config['global_xss_filtering'] = TRUE;

$config['compress_output'] = FALSE;

$config['time_reference'] = 'local';

$config['rewrite_short_tags'] = FALSE;

otn_front.php
Code:
class Otn_front extends Controller {

        function Otn_front()
        {
                // Not necessary, but good practice anyway.
                parent::Controller();

                //Setup the view parts.
                $this->view->part('tpl_header',         'template/tpl-header.php');
                $this->view->part('tpl_right_content',  'template/tpl-right-content.php');
                $this->view->part('tpl_footer',         'template/tpl-footer.php');

                $this->load->model('otndb', '', TRUE);
                // $this->load->model('devblogdb', '', TRUE);

                //Get the menu items, this needs to be done everywhere.
                $this->view->set('otn_devblog_menu', $this->otndb->get_devblog_menu());
                // $this->view->set('otn_devblog_menu_items', $this->devblog->get_menu_items());

                // This output cache will be put into place once the site is live
                // --AND-- getting significant enough traffic to affect performance.
                $this->output->cache(15);

        }

        function index()
        {
                $this->view->set('otn_front_content', $this->otndb->get_devblog_latest(4));
                $this->view->load('common/otn_front');
        }

        function devblog()
        {
                $id = $this->uri->segment(2);
                if(ctype_digit($id))
                {
                        $this->view->set('otn_devblog_single', $this->otndb->get_devblog_single($id));
                        $this->view->load('common/otn_single');
                }
                else
                {
                        redirect('/');
                }
        }

}

I'm completely stumped.

If you go to onlytechnews.com/otn_front/devblog/ - it boots you back to the front with a redirect. So the method works.. It's as if my route is being ignored.
#2

[eluser]Rick Jolly[/eluser]
The line:
$this->uri->segment(2);

would return "devblog", not the id.

I think you need to use $this->uri->rsegment(2);
#3

[eluser]awpti[/eluser]
Right. If you go to http://onlytechnews.com/otn_front/devblog/

the actual URI is http://onlytechnews.com/devblog/#

That's what's not working.

http://onlytechnews.com/otn_front/devblog/ is to show that the method is picking up that it was called with no valid ID (fails ctype_digit() check).
#4

[eluser]awpti[/eluser]
Only thing that I can figure is that my routes.php is being ignored.

I don't get why that would be, since routes breaking would essentially break everything else.

http://www.awpti.org/ works fine as do the routes. ./stumped
#5

[eluser]Pascal Kriete[/eluser]
Careful with the ctype_digit(). It only works if you pass in a string. Because of the way php handles variables it might already be an int. I can't test it right now, but try doing $id = settype($id, "int");

EDIT: Actually, your best bet would probably be is_numeric($id)
#6

[eluser]awpti[/eluser]
Something broke in the Routes class. I dropped a new Routes file from a fresh CI base install and everything is working again.

Maybe I got drunk and editted the file while playing WoW. Who knows.

PHP generally - always in my experience - handles numerical data passed via get/post as strings. I should get into the habit of typecasting, since it will, eventually, become important (If I recall, PHP6 is getting a bit more strict on typecasting).

*shrug*

Color me dumbfounded.




Theme © iAndrew 2016 - Forum software by © MyBB