2011-08-18 41 views
8

我正在使用CodeIgniter並在Ubuntu 10.10雲服務器上安裝了LAMP堆棧。即使啓用了allowoverride,htaccess也無法正常工作

一切都很好,我啓用了Apache userdir模塊,以便我的主目錄位於/home/myapp/public_html,並且我通過訪問servername/~myapp訪問它。

不幸的是,.htaccess重寫似乎沒有工作 - 它導致404說the file /home/myapp/public_html/index.php無法找到 - 404錯誤。

Mod_rewrite已啓用。

我知道你需要設置AllowOverride All指令 - 我把它設置在/etc/apache2/sites-enabled/default - 但重寫似乎沒有正常工作。

.htaccess文件只包含:

RewriteEngine on 
RewriteCond $1 !^(index.php|img|stylesheets|js|icons|robots\.txt|user_guide) 
RewriteRule ^(.*)$ index.php/$1 [L] 

而且我/etc/apache2/sites-available/default樣子:

<VirtualHost *:80> 
ServerAdmin [email protected] 

DocumentRoot /var/www 
<Directory /> 
     Options FollowSymLinks 
     AllowOverride ALL 
</Directory> 
<Directory /var/www/> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride ALL 
     Order allow,deny 
     allow from all 
</Directory> 
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
<Directory "/usr/lib/cgi-bin"> 
     AllowOverride All 
     Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
     Order allow,deny 
     Allow from all 
</Directory> 

ErrorLog ${APACHE_LOG_DIR}/error.log 

最後,/etc/apache2/mods-enabled/userdir.conf樣子:

<IfModule mod_userdir.c> 
     UserDir public_html 
     UserDir disabled root 

     <Directory /home/*/public_html> 
       AllowOverride All 
       Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec 
       <Limit GET POST OPTIONS> 
         Order allow,deny 
         Allow from all 
       </Limit> 
       <LimitExcept GET POST OPTIONS> 
         Order deny,allow 
         Deny from all 
       </LimitExcept> 
     </Directory> 
</IfModule> 

我一直在谷歌上搜索和擺弄幾個小時,任何人都可以幫忙嗎?

回答

14

對於它的價值,我在Ubuntu Server 11.10和LAMP上遇到了非常類似的問題。我不得不運行命令

sudo a2enmod rewrite 

它爲我做了詭計。也許這是你或者其他一些人來這裏的解決方案。

+0

這也適用於我....與Ubuntu 10.10使用laravel具有相同的問題... – ftrotter

+0

這個問題對我來說也是在ubu 12.04LTS上,它工作!!,很高興我們有類似於stackoverflow! – Mazzy

+0

我很高興幫助:) – jonas

相關問題