• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function error

#1
[eluser]Unknown[/eluser]
I am just start with codeigniter 1 day ago
and i create a blog page like the user guide told me

<?php
class Blog extends Controller {

function index()
{
echo 'Hello World!';
}

function com()
{
echo 'Hello World2222222222222!';
}
}
?>

and put the right code on the config file

but only the function index is loading
when i am trying to load the com function its show me the index
i am us this url: http://mydomain.com/blog/com

anyone can help me?

thanks.

#2
[eluser]Pascal Kriete[/eluser]
You're missing index.php in your url.

CodeIgniter uses what is known as a front-controller. That means that all requests go through index.php and CodeIgniter figures out what controller to call. So the url you want is:
[pre]http://example.com/index.php/blog/com[/pre]

It is possible to remove index.php by using a little server trick to rewrite the urls. I won't go into it here, but searching for .htaccess should yield plenty of results.

Welcome to CodeIgniter.

#3
[eluser]Unknown[/eluser]
your right :]

I am not write index.php because i put the .htaccess and do all the things for remove the index.php from
the url.. i will check it again

but why http://ci.easyptc.net/blog or http://ci.easyptc.net
is working well? (with out index.php)


thanks Smile


EDIT: only the main page working without index.php
all the other function not working (only with index.php in the url)
on config i make change on $config['index_page'] = "";
and put a .htaccess file on the root floder (where the index.php is) like this:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.