你可以做到這一點,在config/config.php
:
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST']; //you can also leave blank this CI tend to find this by himself
$config['index_page'] = '';
,試試下列.htaccess
。我用它爲許多網站,它滿足我。
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
如果沒有工作,使用phpinfo();
並檢查是否mod_rewrite的是enabled
。如果未啓用,則可以按照堆棧溢出問題How do you enable mod_rewrite?中的說明啓用該功能。
如果沒有工作,mod_rewrite的是enabled
然而,你可以嘗試在config/config.php
切換這些:
$config['uri_protocol'] = 'AUTO'; //If not working, try one of these:
'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
我不理解你的問題。你認爲你的'.htaccess'文件應該保持爲空,儘管這些文檔正好告訴你放在那裏。解決方案:將其從RTM中取出並按照說明操作。 – Sparky
可能重複的[在codeigniter 2.1.0中刪除index.php](http://stackoverflow.com/questions/9667226/remove-index-php-in-codeigniter-2-1-0) – Sparky