Home » , » Hướng dẫn cách bỏ index.php trong codeigniter

Hướng dẫn cách bỏ index.php trong codeigniter

Đăng bởi: Code.Elite.Vn

Trong bài này chúng ta sẽ biết cách xử lý bỏ index.php trong bộ nguồn codeigniter như thế nào, để bộ nguồn chúng ta thêm rõ ràng và phù hợp với google seo nhé.

đầu tiên chúng ta tạo 1 tập tin với tên gọi là .htaccess nhé với mã nguồn như sau:


<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
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>
Sau khi đã tiến hành tạo file .htaccess và có mã nguồn như trên chúng ta vào application/config.php tìm dòng url để bỏ index.php ra nhé.

Lời kết:

Qua bài này chúng ta đã tiến hành loại bỏ index.php ra khỏi bộ nguồn codeigniter, hy vọng với bài này các bạn có thể áp dụng thành công vào dự án của mình nhé.



0 comments:

Post a Comment