2016-04-27 34 views
0

我已經安裝了LAMP堆棧的Ubuntu 14.04服務器。Apache配置 - 指向Ubuntu中的目錄14.04

我有一個目錄/home/alex/checkhtml其中包括一些測試的PHP和HTML。

我要的是,當我訪問http://localhost/checkhtml/home/alex/checkhtml內容將被顯示(實際上/home/alex/checkhtml/index.html

這裏是我做過什麼:

  1. 轉到:在/ etc/apache2的/ conf-可創造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 /亞歷克斯/ 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. 

有誰知道我在這裏做錯了嗎?

謝謝,最好的問候。

Alex

+0

你想訪問'/家庭/亞歷克斯/ checkhtml',但你已經創建了Apache的php.conf的路徑規則'/家庭/ alex/php' – nidhi

+0

對不起,我的複製和粘貼錯誤。 別名^/checkhtml 「/家/亞歷克斯/ checkhtml」 <目錄/ home /亞歷克斯/ checkhtml> 訂購允許,拒絕 要求所有授權 – AlexPham

回答

0

您應該使用Alias driective進行精確的URL匹配。如果你想使用正則表達式匹配,然後使用AliasMatch指令:

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