2017-03-24 42 views
0

我正在嘗試以下操作。嘗試了很多方法,但似乎沒有任何工作,如果任何人有任何想法,請幫助。在apache2.2中使用Location指令

<Location /MyRoot> 
# '/MyRoot' Should only be allowed, and NONE of its sub should be allowed 
# Requests will be redirected to weblogic 
</Location> 
<Location /MyRoot/MySub1> 
# '/MyRoot/MySub1' Should be allowed, and all its sub domains should be allowed 
# Requests will be redirected to weblogic 
</Location> 
<Location /MyRoot/MySub2> 
# '/MyRoot/MySub1' Should be allowed, and all its sub domains should be allowed 
# Requests will be redirected to weblogic 
</Location> 

什麼我期待着低於

http://host:port/MyRoot/ --- Should be accessible 
http://host:port/MyRoot/MySub1 --- Should be accessible 
http://host:port/MyRoot/MySub2 --- Should be accessible 
http://host:port/MyRoot/MySub1/MySubSub1 --- Should be accessible 
http://host:port/MyRoot/MySub1/MySubSub2 --- Should be accessible 
http://host:port/MyRoot/MySub2/MySubSub1 --- Should be accessible 
http://host:port/MyRoot/MySub2/MySubSub2 --- Should be accessible 
http://host:port/MyRoot/MySub1/MySubSub1 --- Should be accessible 
http://host:port/MyRoot/MySub1/MySubSub2 --- Should be accessible 
http://host:port/MyRoot/ABC --- Should NOT be accessible 
http://host:port/MyRoot/XYZ/LKJ --- Should NOT be accessible 

,並有可能是下MyRoot很多文件夾,我想他們是不同的(MySub1 &畝)

任何人都可以請指教在遙不可及如何實現這一點。

回答

0

至少據我現在所知,這是不可能的,只有根目錄下的.htaccess

你必須使用此代碼創建/MyRoot/.htaccess

Order deny,allow 
Deny from all 
Allow from 127.0.0.1 

爲了避免來自外部用戶的根目錄列表。然後,裏面/MyRoot/MySub1/MySubSub1/MyRoot/MySub1/MySubSub2/MyRoot/MySub2/MySubSub1/MyRoot/MySub2/MySubSub2和連續你必須創建這樣的一個.htaccess

Allow from all 

這應該可以解決你的問題,在某些方面。希望能幫助到你。

+0

謝謝你的迴應,但我不認爲我真的可以使用.htaccess,因爲這些文件夾是從AppServer和Apache服務的,我沒有訪問這些文件夾。所以我不認爲我可以使用'全部拒絕' –