Remove index.php from codeigniter

Hello all
Today I am going to show you, how to remove the index.php part from your codeigniter URL. There are many ways to do it, but based on my previous experience, I got it is the best way to do so. To do so, create a .htaccess file in your directory and copy the following code in your created file.

 

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

 

Now, save this file and run your codeigniter apps. Hopefully, it will work perfectly.

Thanks for reading.

Advertisements

Remove index.php file from codeigniter

Hello friends…
Hope you are fine.  Today I am going to show a necessary part of codeigniter. It’s how to remove index.php file form codeigniter. You know, when you do any apps with codeigniter, then you will face the following link like- http://localhost/codeigniter/index.php/welcome

Now, I we have to delete index.php part from this and our url should be http://localhost/codeigniter/welcome

Ok, lets start. There are few ways to do this. But, I think, the following system is best. That’s why I am showing this…

First of all open to  system > application > config > config.php
Now, find out $config[‘index_page’] = “index.php”; line and do some modification like below
$config[‘index_page’] = “”; 

Oke, now save your file and run your apps. Hope, it is working….
OK, there is another way to remove index.php file form your directory permanently. This is-

Create a “.htaccess” file in the root of CodeIgniter directory, open the file using your favorite text editor, write down the following script and save it: Continue reading

Fatal error: Call to undefined function base_url() in Codeigniter

Hey Guys.
How are you? Hope you are fine. Now, I am going to show how to recover a Fatal Error in codeigniter.

In codeigniter, sometime you will face some fatal error like the below-

Fatal error: Call to undefined function base_url()

If you face that kind of fatal error, then you have to understand this is for base_ulr() function only, nothing else.
You know, base_url() is function is based on url at codeigniter. That’s why, you have to mentioned the url in your controller or autoload.php file. I suggest to put url in your autoload file. Thats why you have to go to your codeigniter directory and open /system/application/config/autoload.php file. Now, find out the $autoload[‘helper’] = array(); line. It can be 54 no line. (Currently I am using the CI version 1.7.3).

Continue reading