Một số ứng dụng cơ bản với Codeigniter
Nếu chúng ta muốn làm quen nhanh với một ứng dụng liên quan đến database với Codeigniter thì xem qua ứng dụng mẫu này:
Remove index.php in Codeigniter
Hôm nay đọc bài này, tôi thấy quan trọng nên xin tác giả mang về đây.
If you work with CodeIgniter, you will soon learn fast enough that the CodeIgniter framework, by default, uses the index.php in its URL. Here’s an example of how the URL would look like with the index.php being visible.
CodeIgniter URL
http://example.com/index.php/news/article/my_article
.htaccess
To remove the index.php from the URL, you will need to add mod rewrite rules to the .htaccess file in your main CodeIgniter directory. Use this code. Change the rewrite base to your own settings.
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /ci/ 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> ErrorDocument 404 /index.php </IfModule>
config.php
In addition, you will need to edit the /application/config/config.php file. Make sure to remove index.php reference within the file.
$config['index_page'] = '';