gpt4 book ai didi

apache - .htaccess 即使启用了 allowoverride 也无法正常工作

转载 作者:太空宇宙 更新时间:2023-11-03 16:43:01 24 4
gpt4 key购买 nike

我正在使用 CodeIgniter,并且刚刚在 Ubuntu 10.10 云服务器上安装了一个 LAMP 堆栈。

一切正常,我启用了 Apache userdir 模块,因此我的主目录位于 /home/myapp/public_html,我通过转到 servername/~ 访问它我的应用程序

不幸的是,.htaccess 重写似乎不起作用 - 它导致 404 提示 the file/home/myapp/public_html/index.php could not be found - 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 dan@danmatthews.me

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>

我已经用谷歌搜索和摆弄了几个小时,有人可以帮忙吗?

最佳答案

就其值(value)而言,我在 Ubuntu Server 11.10 和 LAMP 上遇到了非常相似的问题。我必须运行命令

sudo a2enmod rewrite

这对我有用。也许这是您或其他一些来这里的人的解决方案。

关于apache - .htaccess 即使启用了 allowoverride 也无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7114129/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com