【问题标题】:Apache configuration - Point to a directory in Ubuntu 14.04Apache 配置 - 指向 Ubuntu 14.04 中的目录
【发布时间】:2016-04-27 03:30:37
【问题描述】:

我有一个已经安装了 LAMP 堆栈的 Ubuntu 14.04 服务器。

我有一个目录/home/alex/checkhtml,其中包括一些测试 php 和 html。

我想要的是当我访问http://localhost/checkhtml时,会显示/home/alex/checkhtml的内容(实际上是/home/alex/checkhtml/index.html

这是我所做的:

  1. 转到:/etc/apache2/conf-available 并创建apache-php.conf 文件
  2. 将这些行添加到apache-php.conf:

    Alias ^/php "/home/alex/php" <Directory /home/alex/php> Order allow,deny Require all granted </Directory>

  3. 转到 /home/alex/checkhtml 并创建 .htaccess 并添加以下行:

    <FilesMatch "."> Allow from all </FilesMatch>

  4. 启用apache-php.conf并重启apache

但是,当我尝试时:http://localhost/checkhtml。出现错误:

The requested URL /checkhtml was not found on this server.

有谁知道我在这里做错了什么?

谢谢你和最好的问候。

亚历克斯

【问题讨论】:

  • 你想访问/home/alex/checkhtml,但是你已经在apache-php.conf中为路径/home/alex/php创建了规则
  • 对不起我的复制和粘贴错误。 Alias ^/checkhtml"/home/alex/checkhtml" 命令allow,deny 要求全部授予

标签: apache .htaccess ubuntu


【解决方案1】:

您应该使用别名指令来进行精确的 URL 匹配。如果要使用 Regex 匹配,请使用 AliasMatch 指令:

AliasMatch "^/checkhtml" "/home/alex/checkhtml"
<Directory /home/alex/checkhtml> 
    Require all granted
</Directory>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-23
    • 1970-01-01
    • 2018-08-24
    • 1970-01-01
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 2014-03-15
    相关资源
    最近更新 更多