2014-11-01 94 views
0

我試圖從url中刪除index.php部分。 這裏是我的.htaccess文件從URL中刪除index.php時出現「內部服務器錯誤」

RewriteEngine On 
RewriteBase /faraztest 

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] 

我也改變了config.php文件,但它仍然寫着「內部服務器錯誤」當我把網址中刪除「/index.php/」後去除。請幫忙。

+0

當你在瀏覽器中輸入沒有'/ index.php'的url時,它會保留嗎? – 2014-11-01 18:16:24

+0

不,當我把規定的代碼放在.htaccess文件中時,我甚至不響應localhost/project /並給出這個錯誤 – 2014-11-01 18:23:00

+0

試着在[0123]結尾 – 2014-11-01 22:22:09

回答

1

好吧,我這一個完成!

的config.php

$config['base_url'] = ''; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 

的.htaccess駐留在/faraztest/.htacces

的.htaccess文件

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteBase /faraztest 
RewriteCond $1 !^(index\.php|public|\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 
</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 /faraztest/index.php 
</IfModule> 

和Ba NG!有效!

兩件事我做錯了,我沒有包括

<IfModule mod_rewrite.c> 
</IfModule> 

以及在ErrorDocument 404 /faraztest/index.php我沒有給正確的文件目的地。

+0

你的男人!!!!謝謝! – 2015-04-24 10:46:16

0

下面的設置一直對我有用。如果不能正常工作,請在瀏覽器中查看您的Network選項卡,以查看發生了什麼。

的config.php

$config['base_url'] = 'https://www.example.com/'; 
$config['index_page'] = ''; 

的.htaccess

RewriteEngine On 

RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] 

RewriteCond $1 !^(index\.php|web|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 
+0

試試'[R = 301,L]'而不是'[L]工作要麼.. – 2014-11-01 18:25:38

0

同樣的問題發生在我身上,它看起來像你沒有打開你的mod_rewrite模塊,所以繼續,在你的Apache設置打開mod_rewrite模塊,重新啓動你的服務器,就是這樣。

相關問題