• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
removing index.php from url and load model eror

#1
[eluser]arif[/eluser]
hello every ones


i`m kindly new to CI . and i start to learn using 2.0.2 now i have two problem.

i had an eror when trying to remove index.php on URI, i had trying to add this .htaccess to my .htaccess file conf

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /SabaPay

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>  

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

but wont work . and also i had my modrewrite but i still cannot remove index.php from url
i had remove inde.php in config.php to
Code:
$config['index_page'] = "";
also
Code:
$config['uri_protocol']    = 'REQUEST_URI';

any suggestion ?

the second is
i try to make blog that require login to made a post
the login succusfull but neither the blog. becouse i make two model that is user model and blog model, when i load blog model i hadd an eror 500 but when i adding my blog model method into user model that work succesfully,

my question is why i cannot load the blog model in my case ?

thank for your help

regard

Arif

#2
[eluser]InsiteFX[/eluser]
Error 500 is a server error not a CI Error!

Unless you have some bad code in your Model hard to say because you did not show the code for it!

InsiteFX

#3
[eluser]arif[/eluser]
[quote author="InsiteFX" date="1309625762"]Error 500 is a server error not a CI Error!

Unless you have some bad code in your Model hard to say because you did not show the code for it!

InsiteFX[/quote]

sorry for that now this the code

Code:
&lt;?php
class Blog extends CI_Controller{
    //put your code here
    function __construct() {
        parent::__construct();
        $this->load->model('blog');
      
    }
    function index() {
        

  $data['query']= $this->blog->index();
  
        
   $this->load->view('blog_view', $data);
    }
  
}

and the model
Code:
&lt;?php
class Blog extends CI_Model {
    
     function index(){
      $this->db->select('id,title,body');
                $this->db->from('blogs');
          
                $this->db->order_by('id','ASC');
                $query = $this->db->get();

                return $query;
}
  
}

#4
[eluser]InsiteFX[/eluser]
You should not use index as a function in your model, it is a CI reserved word!

Rename your model index function to something else.

InsiteFX

#5
[eluser]arif[/eluser]
[quote author="InsiteFX" date="1309632474"]You should not use index as a function in your model, it is a CI reserved word!

Rename your model index function to something else.

InsiteFX[/quote]

thanks you that was realy helping . and how about removing index.php in url .. ?? i had tried . using that htacces . but not working on me .

#6
[eluser]InsiteFX[/eluser]
application/config/config.php
Code:
$config['index_page'] = "";

Try this .htaccess file:
Code:
<IfModule mod_rewrite.c>

    <ifModule mod_php5.c>
        php_value default_charset utf-8
    </ifModule>

    Options +FollowSymLinks

    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

    RewriteCond $1 !^(index\.php|assets|css|js|scripts|icons|images|img|media|xml|user_guide|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    <IfModule mod_php5.c>
        RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    </IfModule>

    <IfModule !mod_php5.c>
        RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
    </IfModule>

</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

InsiteFX


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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