2017-01-26 3 views
3

zend framework 2 공용 폴더 (예 : css)에 대한 액세스를 어떻게 제한 할 수 있습니까? http을 통해 폴더에 액세스 할 때 표시되는 디렉토리 목록을 숨기고 싶습니다. 하지만 파일을 응용 프로그램에서 올바르게 사용할 수 있기를 바랍니다.브라우저에서 공용 폴더에 액세스 할 때 디렉토리 목록 숨기기

enter image description here

가상 호스트 구성 :

<VirtualHost *:80> 
    ServerName server1.jobsoft.co 
    ServerAlias server1.jobsoft.co 
    DocumentRoot /var/www/html/engsvc_dev/public 
    ErrorLog /var/log/httpd/engsvc_dev.error.log 
    CustomLog /var/log/httpd/engsvc_dev.common.log common 

    <Directory /var/www/html/engsvc_dev/public> 

      DirectoryIndex index.php 
      Options Indexes FollowSymLinks MultiViews 
      AllowOverride All 
      Order allow,deny 
      Allow from all 

    </Directory> 

.htaccess 파일 :

이 디렉토리 목록은 내 도메인의 css 폴더에 액세스 할 때 나타납니다

RewriteEngine on 

RewriteCond %{HTTP_HOST} ^(www.)?server1.jobsoft.co$ 
RewriteCond %{REQUEST_URI} !^/engsvc_dev/public/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /public/$1 

RewriteCond %{HTTP_HOST} ^(www.)?server1.jobsoft.co$ 
RewriteRule ^(/)?$ /public/index.php [L] 

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteRule ^(.*)$ public/$1 [L] 
</IfModule> 
+0

'css' 파일은 일반적으로 공개적으로 액세스 할 수 있어야합니다. * "응용 프로그램에서 올바르게 사용"*하는 것은 무엇을 의미합니까? 클라이언트 측 응용 프로그램/코드에서 사용하려는 경우 공개적으로 액세스 할 수 있어야합니다. 서버 측 코드에서 사용하려는 경우이 파일을 공용 폴더에서 제거하는 것이 좋습니다. – Wilt

+0

브라우저에서 구조를 표시하고 싶지 않거나 불가능합니다. –

+0

[여기] (https://www.thesitewizard.com/apache/prevent-directory-listing-htaccess.shtml) 또는 [여기] (http://stackoverflow.com/questions/2530372/how-do-i)를 확인하십시오. -disable-directory-browsing) – Wilt

답변

2

귀하의 질문을 편집하고 화면에 표시되는 파일 목록을 일반적으로 호출하는 방식이므로 "디렉토리 목록"이라는 용어를 추가했습니다. 처음에 나는 당신이 당신의 질문을 읽은 후 무엇을 원했는지 알지 못했습니다. 그러나 당신의 코멘트 후에 나는 그것을 얻었다.

일반적으로 Apache 서버에 대한 .htaccess 파일에 추가 규칙을 추가하여 디렉토리 목록을 방지 할 수 있습니다.

herehere 또는 그 이상인 by searching the topic on stackoverflow과 같이 많은 방법으로 게시물을 확인할 수 있습니다.

마법으로 해제되어 있습니다 :

Options -Indexes 

그리고 당신이 장 옵션 지침에서 다음을 읽을 수 this apache documentation에서

Options +Indexes 

으로 설정 :

색인 디렉토리에 매핑되는 URL이 요청되고 해당 디렉토리에 DirectoryIndex (예 : index.html)이없는 경우 mod_autoindex은 해당 디렉토리의 형식 목록을 반환합니다.

관련 문제