CodeIgniter index.php 제거하기

http://oozman.com/php-tutorials/remove-index-php-codeigniter-windows/

http://www.cikorea.net/lecture/view/213/page/1

 

Hi guys, just want to share with you this simple solution on how to remove index.php in your CodeIgniter’s URL if you’re using a server based in Windows. Like me, I develop most of my application using my Windows platform and sometimes, there are things that won’t work on Windows but works perfectly on Linux/UNIX platforms.

And the best example of this scenario is the “how to remove index.php in CodeIgniter”. As you’ve noticed, CodeIgniter does include the solution to this problem, but unfortunately, it won’t work when you are using a server deployed in Windows. So, I’m thinking that this will be useful with you as well.

Here is the default solution given by CodeIgniter in there cool framework documentation:
You should copy this code below to your .htaccess that must recide on your CI root directory.

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

But, as I said, this won’t work on Windows, except if you’re running on a server deployed using Linux/UNIX.

So, to make things work on Windows. You can check this working solution that I personally used. It has some additional steps, but it’s super easy to do.

Step 1:
Create a .htaccess file (in your CI root folder) and copy this code below.

  1. RewriteEngine On
  2. RewriteBase /YOUR-CI-ROOT-FOLDER
  3. RewriteCond %{REQUEST_URI} ^system.*
  4. RewriteRule ^(.*)$ /index.php/$1 [L]
  5. RewriteCond %{REQUEST_FILENAME} !-f
  6. RewriteCond %{REQUEST_FILENAME} !-d
  7. RewriteRule ^(.*)$ index.php/$1 [L]

Note: You need to replace “YOUR-CI-ROOT-FOLDER” with your correct CI application folder.
Ex: If you installed your CI application to, http://localhost/APPS/CIApp. Then you need to replace “YOUR-CI-ROOT-FOLDER” by “APPS/CIApp“.

Step 2:
Go to you “application/config” folder and edit this line of code in your “config.php”.

  1. //from $config[‘index_page’] = ‘index.php’;
  2. //to
  3. $config[‘index_page’] = ”;

Now, check you can access your CI URLs without adding “index.php”. At this point, everything should work perfectly.
But in case, it doesn’t work, you can do this optional step below:

Optional Step:
Go to you “application/config” folder and edit this line of code in your “config.php”.

  1. //from $config[‘uri_protocol’]  = ‘AUTO’;
  2. //to
  3. $config[‘uri_protocol’] = ‘REQUEST_URI’;

So, there you have it. I hope this will help you as well. If you have any questions or suggestions, please feel free to comment below.

Best Regards.

19 Replies to “CodeIgniter index.php 제거하기”

Leave a Reply

Your email address will not be published.