php – EC2 Mod重写AllowOverRide None更改为All

How to edit httpd.conf file in AMAZON EC2

codeigniter .htaccess in amazon ec2 removal of index.php not working

当我读到上述问题时,我意识到我的问题与他们一样.所以,我应该更改我的Amazon EC2实例中的httpd.conf文件,以使我的htaccess文件正常工作.

我通过ssh客户端连接到我的实例,Linux终端我执行下面的代码.

 sudo nano /etc/httpd/conf/httpd.conf

这段代码的结果我看到了这个页面:

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.

所以,看到这个后我不知道该怎么办.我将把AllowOverRide None改为AllowOverRide All,因为我没有看到这样的东西.

在将AllowOverRide None更改为AllowOverRide All之后,我应该使用任何命令重新启动服务器.

最佳答案 您不希望乱用httpd.conf文件来添加AllowOverride.您应该在要启用htaccess文件的虚拟主机的vhost配置中执行此操作.

否则,如果你不能修改vhost配置(或者根本就没有),那么只需将其添加到httpd.conf:

<Directory />
    Options None
    AllowOverride All
    Order deny,allow
    Deny from all
</Directory>

<Directory /path/to/your/htdocs/>
    AllowOverride All
</Directory>

/ path / to / your / htdocs /是htaccess文件或文档根目录的位置.

点赞