[問題]Apache怎麼隱藏資料夾的內容
版主: 版主管理群
版面規則
本區是討論關於 phpBB 2.0.X 架設安裝上的問題,只要有安裝任何外掛,請到外掛討論相關版面按照公告格式發表。
(發表文章請按照公告格式發表,違者砍文)
本區是討論關於 phpBB 2.0.X 架設安裝上的問題,只要有安裝任何外掛,請到外掛討論相關版面按照公告格式發表。
(發表文章請按照公告格式發表,違者砍文)
[問題]Apache怎麼隱藏資料夾的內容
我因為要架設phpbb,
所以我下載了appserv 1.90版安裝,
可是我發現Apache如果使用者直接打我的網址再加上資料夾名稱的話,
可以看到我該資料夾的內容耶!
該怎樣設定使Apache有辦法像IIS一樣禁止其他使用者看到資料夾內容,
不然大家都看的到我網頁有放什麼檔案,
這樣很困擾耶!
●架設主機作業系統:Windows 2000 professional
●上網方式:ADSL固接
●安裝的程式:appserv 1.9.0
●phpBB2 版本:2.0.4
所以我下載了appserv 1.90版安裝,
可是我發現Apache如果使用者直接打我的網址再加上資料夾名稱的話,
可以看到我該資料夾的內容耶!
該怎樣設定使Apache有辦法像IIS一樣禁止其他使用者看到資料夾內容,
不然大家都看的到我網頁有放什麼檔案,
這樣很困擾耶!
●架設主機作業系統:Windows 2000 professional
●上網方式:ADSL固接
●安裝的程式:appserv 1.9.0
●phpBB2 版本:2.0.4
Re: [問題]Apache怎麼隱藏資料夾的內容
最簡單的方法:放一個空白的檔案,取名叫做 index.htmlaack 寫:我因為要架設phpbb,
\n所以我下載了appserv 1.90版安裝,
可是我發現Apache如果使用者直接打我的網址再加上資料夾名稱的話,
可以看到我該資料夾的內容耶!
該怎樣設定使Apache有辦法像IIS一樣禁止其他使用者看到資料夾內容,
不然大家都看的到我網頁有放什麼檔案,
這樣很困擾耶!
●架設主機作業系統:Windows 2000 professional
●上網方式:ADSL固接
●安裝的程式:appserv 1.9.0
●phpBB2 版本:2.0.4
正確一點的做法:在 httpd.conf 加上
代碼: 選擇全部
<Directory "D:/Inetpub/wwwroot/"> #你要設定的目錄在 Windows 裡面的名稱\r
Options FollowSymLinks #還要加什麼設定可以自己參考 Apache Manual 加上去\r
</Directory>
Re: [問題]Apache怎麼隱藏資料夾的內容
修改了, 也restart, 但還是會顯示資料夾內容出來chiouss 寫:正確一點的做法:在 httpd.conf 加上代碼: 選擇全部
<Directory "D:/Inetpub/wwwroot/"> #你要設定的目錄在 Windows 裡面的名稱\r Options FollowSymLinks #還要加什麼設定可以自己參考 Apache Manual 加上去\r </Directory>
間中上來走走吧~
你先在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.
請試試看吧!!!(我已有試過一遍了)
在這行上面貼上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.
請試試看吧!!!(我已有試過一遍了)
謝謝啦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的錯誤頁, 是不是改成這樣: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.
請試試看吧!!!(我已有試過一遍了)
代碼: 選擇全部
# 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
間中上來走走吧~
執行這個程式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
因該這樣別人就不能跑去其他的目錄了
他會跳出文件給你修改在最上面有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
因該這樣別人就不能跑去其他的目錄了
我來解說一下好了,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 裡面設定
阿簡單一點的方法就是在 blah2 的目錄底下放一個空白的 index.html,這樣子誰也看不到裡面的東西了
同樣的,要是你 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>