2013-04-11 110 views
2

我在ubuntu 12.10上使用apache2。但htaccess的不工作,這是我的htaccess文件:codeigniter 2.1.3 htaccess不工作

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /ci/ 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule> 
<IfModule mod_security.c> 
    SecFilterEngine Off 
    SecFilterScanPOST Off 
</IfModule> 


$config['base_url'] = 'http://localhost/ci/index.php'; 
$config[‘index_page’] = 「」; 
$config[‘uri_protocol’] = 「AUTO」; 


1 http://localhost/ci/index.php/site/about 
2 http://localhost/ci/site/about 

的第一部作品,但我想第二個工作任何想法如何讓它起作用。謝謝

404 Not Found 
The requested URL /ci/site/about was not found on this server. 
+1

儘量去除$配置[ 'BASE_URL'] = 'HTTP://localhost/ci/index.php';到$ config ['base_url'] ='' – 2013-04-11 05:55:33

+0

仍然是相同的錯誤信息 – mercy 2013-04-11 06:05:20

回答

0

您是否啓用了mod重寫?

設置你的htaccess(樣品)

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    #RewriteBase/

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [QSA,L] 
</IfModule> 

刪除的index.php在你的配置

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

也讓壓倒一切的htaccess在Apache

/etc/apache2/sites-available/default 

和編輯文件&更改爲

AllowOverride All 

,當你喜歡你的工作重新啓動Apache

+1

apache rewritemode是AllowOverride所有,但我不斷收到此請求的URL/ci/site/about在此服務器上找不到。 – mercy 2013-04-11 03:30:26

+0

嘗試設置您的baseurl ='' – Dino 2013-04-11 03:33:33

+0

我的基本網址是$ config ['base_url'] \t ='http://localhost/ci/index.php';仍然我得到了同樣的錯誤信息 – mercy 2013-04-11 03:36:28

0

這裏是我的設置是這樣,而我的作品:

的.htaccess

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 

的config.php

$config['index_page'] = ''; 
$config['base_url'] = 'http://localhost/icms/'; 

我認爲這就是我改變的一切,使我的工作。

希望它有幫助。

問候,

Kobus

+0

謝謝先生kobus你的幫助,但我確實喜歡你確切地告訴我,我不斷收到請求的URL/ci/site/about在這臺服務器上找不到。 apache LOG file [Thu Apr 11 20:10:10 2013] [error] [client 127.0.0.1]文件不存在:/ var/www/ci/site – mercy 2013-04-11 19:12:13

+0

因此,你的$ config ['index_page']是空白的,並且$ config ['base_url']等於'http:// localhost/ci /'。當你轉到http://localhost/ci/index.php/site/about時,你的頁面可以正常工作,但是當你轉到http:// localhost/ci/site/about時,它不會?我唯一能想到的是,你沒有把.htaccess信息放在右邊的.htaccess文件中。我以前做過。它必須是網站文件夾根目錄中的文件夾,而不是應用程序文件夾中的文件夾。除此之外,我很抱歉,但我沒有任何其他幫助,因爲我的作品,因爲它在那裏... – 2013-04-12 08:49:03

+0

我試過每一件事,但它不工作,當我嘗試localhost/ci/site /關於它顯示索引.PHP – mercy 2013-04-18 20:35:31