我正在使用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>
我一直在谷歌上搜索和擺弄幾個小時,任何人都可以幫忙嗎?
這也適用於我....與Ubuntu 10.10使用laravel具有相同的問題... – ftrotter
這個問題對我來說也是在ubu 12.04LTS上,它工作!!,很高興我們有類似於stackoverflow! – Mazzy
我很高興幫助:) – jonas