[問題]Apache怎麼隱藏資料夾的內容

phpBB Installation & Usage Support
phpBB 2 安裝於各類型作業平台之問題討論;外掛問題,請到相關版面依發問格式發表!
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

版面規則
本區是討論關於 phpBB 2.0.X 架設安裝上的問題,只要有安裝任何外掛,請到外掛討論相關版面按照公告格式發表。
(發表文章請按照公告格式發表,違者砍文)
主題已鎖定
aack
星球公民
星球公民
文章: 62
註冊時間: 2003-06-05 13:54
來自: 台灣

[問題]Apache怎麼隱藏資料夾的內容

文章 aack »

我因為要架設phpbb,
所以我下載了appserv 1.90版安裝,
可是我發現Apache如果使用者直接打我的網址再加上資料夾名稱的話,
可以看到我該資料夾的內容耶!
該怎樣設定使Apache有辦法像IIS一樣禁止其他使用者看到資料夾內容,
不然大家都看的到我網頁有放什麼檔案,
這樣很困擾耶!
●架設主機作業系統:Windows 2000 professional
●上網方式:ADSL固接
●安裝的程式:appserv 1.9.0
●phpBB2 版本:2.0.4
chiouss
竹貓忠實會員
竹貓忠實會員
文章: 1741
註冊時間: 2002-11-29 18:19

Re: [問題]Apache怎麼隱藏資料夾的內容

文章 chiouss »

aack 寫:我因為要架設phpbb,
\n所以我下載了appserv 1.90版安裝,
可是我發現Apache如果使用者直接打我的網址再加上資料夾名稱的話,
可以看到我該資料夾的內容耶!
該怎樣設定使Apache有辦法像IIS一樣禁止其他使用者看到資料夾內容,
不然大家都看的到我網頁有放什麼檔案,
這樣很困擾耶!
●架設主機作業系統:Windows 2000 professional
●上網方式:ADSL固接
●安裝的程式:appserv 1.9.0
●phpBB2 版本:2.0.4
最簡單的方法:放一個空白的檔案,取名叫做 index.html :mrgreen:
正確一點的做法:在 httpd.conf 加上

代碼: 選擇全部

<Directory "D:/Inetpub/wwwroot/">  #你要設定的目錄在 Windows 裡面的名稱\r
   Options FollowSymLinks   #還要加什麼設定可以自己參考 Apache Manual 加上去\r
</Directory>
比較不建議使用的方法:把 httpd.conf 裡面 LoadModule autoindex_module 這行前面加上 # 以後重跑 Apache
william91
竹貓忠實會員
竹貓忠實會員
文章: 642
註冊時間: 2003-04-16 20:53
來自: 牛牛農場
聯繫:

Re: [問題]Apache怎麼隱藏資料夾的內容

文章 william91 »

chiouss 寫:正確一點的做法:在 httpd.conf 加上

代碼: 選擇全部

<Directory "D:/Inetpub/wwwroot/">  #你要設定的目錄在 Windows 裡面的名稱\r
   Options FollowSymLinks   #還要加什麼設定可以自己參考 Apache Manual 加上去\r
</Directory>
修改了, 也restart, 但還是會顯示資料夾內容出來
間中上來走走吧~
jt3
星球公民
星球公民
文章: 88
註冊時間: 2003-04-23 12:44

文章 jt3 »

william91
竹貓忠實會員
竹貓忠實會員
文章: 642
註冊時間: 2003-04-16 20:53
來自: 牛牛農場
聯繫:

文章 william91 »

謝謝啦^^

但如果有這情況, 就會出現:
Forbidden
You don't have permission to access /appserv/ on this server.


--------------------------------------------------------------------------------

Apache/1.3.27 Server at william91.no-ip.com Port 80
可以美化一下, 改成自己想要顯示的網頁嗎?
間中上來走走吧~
jt3
星球公民
星球公民
文章: 88
註冊時間: 2003-04-23 12:44

文章 jt3 »

你先在http.conf檔搜尋# 3) external redirects
在這行上面貼上ErrorDocument 403 /404.htm
當然了,你網站首頁的資料夾內有一個404.htm檔
附上一小段參考:
# 1) plain text
#ErrorDocument 500 "The server made a boo boo.
# n.b. the single leading (") marks it as text, it does not get output
#
# 2) local redirects
#ErrorDocument 404 /missing.html
# to redirect to local URL /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
# N.B.: You can redirect to a script or a document using server-side-includes.
ErrorDocument 403 /404.htm <==就是這行

#
# 3) external redirects
#ErrorDocument 402 http://some.other_server.com/subscription_info.html
# N.B.: Many of the environment variables associated with the original
# request will *not* be available to such a script.
請試試看吧!!!(我已有試過一遍了)
william91
竹貓忠實會員
竹貓忠實會員
文章: 642
註冊時間: 2003-04-16 20:53
來自: 牛牛農場
聯繫:

文章 william91 »

jt3 寫:你先在http.conf檔搜尋# 3) external redirects
在這行上面貼上ErrorDocument 403 /404.htm
當然了,你網站首頁的資料夾內有一個404.htm檔
附上一小段參考:
# 1) plain text
#ErrorDocument 500 "The server made a boo boo.
# n.b. the single leading (") marks it as text, it does not get output
#
# 2) local redirects
#ErrorDocument 404 /missing.html
# to redirect to local URL /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
# N.B.: You can redirect to a script or a document using server-side-includes.
ErrorDocument 403 /404.htm <==就是這行

#
# 3) external redirects
#ErrorDocument 402 http://some.other_server.com/subscription_info.html
# N.B.: Many of the environment variables associated with the original
# request will *not* be available to such a script.
請試試看吧!!!(我已有試過一遍了)
謝謝啦 :-P
間中上來走走吧~
aack
星球公民
星球公民
文章: 62
註冊時間: 2003-06-05 13:54
來自: 台灣

文章 aack »

我照著做已經ok囉!
謝謝諸位的幫忙!
william91
竹貓忠實會員
竹貓忠實會員
文章: 642
註冊時間: 2003-04-16 20:53
來自: 牛牛農場
聯繫:

文章 william91 »

jt3 寫:你先在http.conf檔搜尋# 3) external redirects
在這行上面貼上ErrorDocument 403 /404.htm
當然了,你網站首頁的資料夾內有一個404.htm檔
附上一小段參考:
# 1) plain text
#ErrorDocument 500 "The server made a boo boo.
# n.b. the single leading (") marks it as text, it does not get output
#
# 2) local redirects
#ErrorDocument 404 /missing.html
# to redirect to local URL /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
# N.B.: You can redirect to a script or a document using server-side-includes.
ErrorDocument 403 /404.htm <==就是這行

#
# 3) external redirects
#ErrorDocument 402 http://some.other_server.com/subscription_info.html
# N.B.: Many of the environment variables associated with the original
# request will *not* be available to such a script.
請試試看吧!!!(我已有試過一遍了)
如果我要設定403的錯誤頁, 是不是改成這樣:

代碼: 選擇全部

#    2) local redirects
#ErrorDocument 404 /missing.html
#  to redirect to local URL /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
#  N.B.: You can redirect to a script or a document using server-side-includes.
#ErrorDocument 403 /404.htm 
那設定404又怎樣呢?
間中上來走走吧~
jt3
星球公民
星球公民
文章: 88
註冊時間: 2003-04-23 12:44

文章 jt3 »

在ErrorDocument 403 /404.htm這行下面加上一行:
ErrorDocument 404 /404.htm
試試看吧!(我也有試過一遍了~~)
william91
竹貓忠實會員
竹貓忠實會員
文章: 642
註冊時間: 2003-04-16 20:53
來自: 牛牛農場
聯繫:

文章 william91 »

jt3 寫:在ErrorDocument 403 /404.htm這行下面加上一行:
ErrorDocument 404 /404.htm
試試看吧!(我也有試過一遍了~~)
不行........
間中上來走走吧~
benadsl
星球普通子民
星球普通子民
文章: 5
註冊時間: 2003-06-15 00:08

文章 benadsl »

執行這個程式Edit the Apache httpd.conf Configuration File[注一]
他會跳出文件給你修改在最上面有3行

DocumentRoot "目錄"
ServerName 你的區網\r
Port 80

範例
DocumentRoot "C:/APPSERV/www/HOME/"
ServerName phpbb-tw.net
Port 80

那你打上http://phpbb-tw.net 他會直接導覽到 HOME的資料夾\r
就算別人打上http://phpbb-tw.net/phpMyAdmin
也進不了你的資料庫 因為他會變成
"http://phpbb-tw.net/HOME/phpMyAdmin"

記得改好後要執行Restart[注二]

注一 Edit the Apache httpd.conf Configuration File在\r
程式 > AppServ > Apache Configure Server > Edit the Apache httpd.conf Configuration File

注二 Restart在\r
程式 > AppServ > Apache Control Server > Restart

因該這樣別人就不能跑去其他的目錄了
chiouss
竹貓忠實會員
竹貓忠實會員
文章: 1741
註冊時間: 2002-11-29 18:19

文章 chiouss »

我來解說一下好了,Apache 裡面目錄的設定是繼承上一層的設定的,所以假如 http://ooo.xxx.net/blah/ 的目錄權限設定中 Options 沒有 Indexes 這一項的話,http://ooo.xxx.net/blah/blah2/ 這個目錄要是沒有 index file(通常是 index.html 或是 index.php) Apache 就會送出 403 Forbidden。

同樣的,要是你 http://ooo.xxx.net/blah/ 的權限有 Indexes,但是你不想讓 http://ooo.xxx.net/blah/blah2/ 裡面的檔案可以 list,麻煩一點的方法就是在 httpd.conf 裡面設定

代碼: 選擇全部

<Directory "/home/www/blah/blah2">  #假設這是機器上 blah2 的實際路徑
   Options ooo xxx   #看需要什麼就給什麼,不要有 Indexes 這項就是了
   ooo
   xxx
</Directory>
阿簡單一點的方法就是在 blah2 的目錄底下放一個空白的 index.html,這樣子誰也看不到裡面的東西了 :D
jt3
星球公民
星球公民
文章: 88
註冊時間: 2003-04-23 12:44

文章 jt3 »

william91 寫:
jt3 寫:在ErrorDocument 403 /404.htm這行下面加上一行:
ErrorDocument 404 /404.htm
試試看吧!(我也有試過一遍了~~)
不行........
404 找不到網頁
你要在你的網址列中,輸入你一個不存在的網頁,看能不能跑到你指定404那個網頁
網頁最好醒目的不同,你才好分辨!!!
kewo
版務實習幹部
版務實習幹部
文章: 18
註冊時間: 2003-04-14 23:02

文章 kewo »

各位大大:
我的也有相同問題
不過各位的解說我有點霧煞煞,
如果我把資料夾名稱直接改掉,比如說多加幾個單字
讓內行人無法猜到資料夾名稱的話,
這樣可以嗎?
會不會對整個論壇有所影響?
謝謝大家!
主題已鎖定

回到「phpBB 2 安裝與使用」