I use Ubuntu 14.04, Nginx 1.4.6, php5-fpm, Codeigniter 2.2.0 It will remove index.php, and access Codeigniter site normally. Clean configuration “/etc/nginx/site-enabled/default”: server { #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START listen 80; listen [::]:80 default_server ipv6only=on; root /YOUR/PROJECT/ROOT; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name localhost; #location ~* .(ico|css|js|gif|jpe?g|png)(?[0-9]+)?$ { # expires max; # log_not_found off; #} location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404.

Continue reading

首先,是先簡單說明使用 Codeigniter framework 時移除 URL 中的 index.php 在 Codeigniter 的根目錄新增一 .htaccess 檔案 並放入以下內容 RewriteEngine on RewriteCond $1 !^(index\.php|js|robots\.txt|css) RewriteRule ^(.*)$ index.php/$1 [L] 另外還要修改 Codeigniter 的 config.php 設定 $config['index_page'] = ''"; 不過上面的 rewrite rule 有些問題, 情境是這樣的: 我在 Codeigniter 根目錄新增一資料夾為 uploads , 放置上傳的圖片與影片, 但是因為 rewrite rule routing 的關係沒辦法讀取到圖片, 因此我將 .htaccess 檔修改如下: RewriteEngine on RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA] 主要是在三四行的 %{REQUEST_FILENAME} 這樣修改完就解決問題了! ref: CodeIgniter 如何去掉 URL 中的 index.

Continue reading

Author's picture

kerkerj

Cat lover <3

Backend Engineer

Taiwan