我想從CodeIgniter中的路徑中刪除index.php。我無法從CodeIgniter URL中刪除index.php
我試圖更改配置文件爲以下index_page的價值:
$config['index_page'] = '';
然後我嘗試了所有這些的.htaccess:
RewriteEngine on
RewriteBase/
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
Options -Indexes
RewriteEngine on
RewriteCond $1 !^(index\.php|assets/|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<Files "index.php">
AcceptPathInfo On
</Files>
但他們都沒有工作。
我也試圖給uri_protocol改成這樣:
$config['uri_protocol'] = 'ORIG_PATH_INFO';
但它仍然無法正常工作。
我該如何解決這個問題?
編輯:
我想這個代碼,以檢查是否mod_rewrite的啓用:
<?php
if(! function_exists('apache_get_modules')){ phpinfo(); die; }
$result = ' not available';
if(in_array('mod_rewrite',apache_get_modules())) $result = 'available';
?>
<p><?php echo apache_get_version(),"</p><p>mod_rewrite $result"; ?></p>
我得到這樣的結果:
的Apache/2.2.22(Ubuntu的)
mod_rewrite不可用
嘗試設置URL協議自動''$配置[ 'uri_protocol'] = '自動','' –
你的htaccess看起來不錯。你確定你的網絡服務器支持htaccess並啓用了mod_rewrite嗎? –
@jonijones我已經這樣做了,但同樣的問題:/ –