2015-09-06 98 views
0

我在做基本身份驗證以通過調度程序訪問網頁。我已經通過一些博客,並能夠實現它,但只能用於一個目錄。以下是我配置的虛擬主機。Apache Http基本身份驗證 - 禁止錯誤403

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName aemcorner.com 
    ServerAlias www.aemcorner.com 
    #DocumentRoot /var/www/example.com/public_html 
     DocumentRoot /opt/communique/dispatcher/cache 
     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 
     <Directory /content/practice/en/hello/secure-pages> 
    # <Directory /var/www/example.com/public_html> 
      AuthType Basic 
      AuthName "Secure Content" 
      AuthBasicProvider file 
      AuthUserFile /etc/apache2/passwords 
      Require all granted 
     </Directory> 
</VirtualHost> 

在這裏,我想用註釋行工作,這段代碼工作正常,但當我 與/內容替換/實習/ EN /安全 - 網頁和使用評價的DocumentRoot它給我一個錯誤如下圖所示:

**Forbidden 
You don't have permission to access /content/practice/en/hello/secure-pages/sp1.html on this server.** 

我要訪問的頁面/opt/communique/dispatcher/cache/content/practice/en/Secure-Pages/SP1.html

而且我收到以下錯誤:

[Mon Sep 07 20:57:39.500158 2015] [authz_core:error] [pid 9483:tid 140017092585216] [client 127.0.0.1:49543] AH01630: client denied by server configuration: /opt/communique/dispatcher/cache/favicon.ico, referer: http://aemcorner.com/content/practice/en/hello/secure-pages/sp1.html 
+0

您試圖訪問該文件的路徑不中您嘗試允許訪問的目錄的路徑。還要確保你的大小寫敏感。嘗試轉到'' – TomNash

+0

是的,當我點擊http://aemcorner.com/content/practice/en/hello/secure-pages/sp1 .html網址,它給了我相同的信息您無權訪問此服務器上的/content/practice/en/hello/secure-pages/sp1.html。更新問題也 – zdhim

回答

1

我可以通過下面的配置來解決這個問題:

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName aemcorner.com 
    ServerAlias www.aemcorner.com 
    #DocumentRoot /var/www/example.com/public_html 
     DocumentRoot /opt/communique/dispatcher/cache 
     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 
     <Location /content/practice/en/hello/secure-pages> 
    # <Directory /var/www/example.com/public_html> 
      AuthType Basic 
      AuthName "Secure Content" 
      AuthBasicProvider file 
      AuthUserFile /etc/apache2/passwords 
      Require valid-user 
     </Location> 
</VirtualHost> 

我使用Location代替目錄和Require valid-user