使用 Apache2 在 Ubuntu 12.04 上启用 htaccess 错误 [英] Enable htaccess error on Ubuntu 12.04 with Apache2

查看:34
本文介绍了使用 Apache2 在 Ubuntu 12.04 上启用 htaccess 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试启用 htaccess.我改了:

I tried to enable htaccess. I changed:

<Directory /var/www/abc.biz/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

致:

<Directory /var/www/abc.biz/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

但我收到 500(内部服务器)错误.为什么?

But I'm getting 500 (Internal Server) error. Why?

这是我的 /etc/apache2/sites-available/default 文件:

<VirtualHost *:80>
ServerAdmin admin@abc.biz

DocumentRoot /var/www/abc.biz
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/abc.biz/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

推荐答案

我认为你需要更改/etc/apache2/sites-available/default 的这部分

I think you need to change this part of your /etc/apache2/sites-available/default

DocumentRoot /var/www/abc.biz
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/abc.biz/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

DocumentRoot /var/www/abc.biz
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
<Directory /var/www/abc.biz/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

因为一开始 AllowOverride All 您允许使用 .htaccess 文件覆盖整个 apache 的设置,但您还需要在 <Directory/var/www/abc.biz/> 更改它.AllowOverride All 用于您的特定主机目录,您的网站所在的目录.此外,您应该检查放置在/var/www/abc.biz 目录中的 .htaccess 文件是否正确写入,因为当您启用 .htaccess 文件以覆盖全局 apache 设置时,错误的 .htaccess 文件会导致此类错误.

Because at first <Directory /> AllowOverride All you allow to override settings with your .htaccess file for the whole apache, but also you need to change it at <Directory /var/www/abc.biz/> AllowOverride All for your specific host directory, where your web site is placed. Also you should check .htaccess files placed in your /var/www/abc.biz directory to be correctly writen, because when you enable .htaccess files to override global apache settings wrong .htaccess file causes such error.

这篇关于使用 Apache2 在 Ubuntu 12.04 上启用 htaccess 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆