我正在使用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