php - EC2 Mod Rewrite 将 AllowOverRide None 更改为 All

标签 php apache .htaccess amazon-web-services amazon-ec2

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 之后,我是否应该使用任何命令重新启动服务器。

最佳答案

您不想为了添加 AllowOverride 而弄乱 httpd.conf 文件。您应该在要在其中启用 htaccess 文件的虚拟主机的虚拟主机配置中执行此操作。

否则,如果您无法修改 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 文件或文档根目录所在的位置。

关于php - EC2 Mod Rewrite 将 AllowOverRide None 更改为 All,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19426767/

相关文章:

javascript - 如何在 html 电子邮件模板中覆盖 gmail 视口(viewport)?

php - MySQL、PHP - 从 mysql 检索数据并通过电子邮件发送

apache - hive 未能显示仓库中的表

php - mod_rewrite 不适用于 jQuery.ajax

php - 通过 .htaccess 将 $_GET 变量传递给虚拟目录

php - SQL自定义搜索函数: unable to join two tables

php - 在 WordPress 的表中显示数据库数据

php - 使用 PHP/MySQL 搜索网站的最佳方式?

regex - 添加假饲料以与 apache mod_rewrite 一起使用

.htaccess url 使用 ssl 重定向重写