Apache配置 - 指向Ubuntu 14.04中的目录

时间:2016-04-27 03:30:38

标签: apache .htaccess ubuntu

我已经安装了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

  5. 然而,当我尝试:http://localhost/checkhtml时。出现错误:

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

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

    谢谢你,并致以最诚挚的问候。

    亚历

1 个答案:

答案 0 :(得分:0)

您应该使用Alias driective进行精确的URL匹配。如果要使用正则表达式匹配,请使用AliasMatch指令:

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