2014-04-18 1 views
1

내 페이지에서 실버 스트라이프 프레임 워크를 하위 폴더 current에 설치했습니다. 두 개의 .htaccess 개의 파일을 사용하여 URL에서 "현재"디렉토리를 제거합니다. 루트에 하나 :.htaccess : 하위 폴더로 내부 재 작성, 하위 폴더를 통한 액세스 거부

루트 htaccess로 다음 current 폴더에서

AddOutputFilterByType deflate text/html text/plain text/css text/javascript application/javascript application/x-javascript application/rss+xml 
# Deployment scripts 
RewriteCond %{REQUEST_FILENAME} /deploy/ 
RewriteRule ^(.*)$ $1 [L] 


### SILVERSTRIPE START ### 
# See: http://www.silverstripe.org/installing-silverstripe/show/12328#post283997 
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /current/ 
    RewriteRule ^(.*)$ /current/$1 
</IfModule> 
### SILVERSTRIPE END ### 

AddHandler application/x-httpd-php54 .php 

과 하나

### SILVERSTRIPE START ### 
<Files *.ss> 
    Order deny,allow 
    Deny from all 
    Allow from 127.0.0.1 
</Files> 

<Files web.config> 
    Order deny,allow 
    Deny from all 
</Files> 

ErrorDocument 404 /assets/error-404.html 
ErrorDocument 500 /assets/error-500.html 

<IfModule mod_alias.c> 
    RedirectMatch 403 /silverstripe-cache(/|$) 
</IfModule> 

<IfModule mod_rewrite.c> 
    SetEnv HTTP_MOD_REWRITE On 
    RewriteEngine On 
    RewriteBase '/' 

    RewriteCond %{REQUEST_URI} ^(.*)$ 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule .* framework/main.php?url=%1&%{QUERY_STRING} [L] 
</IfModule> 
### SILVERSTRIPE END ### 

이 설정의 문제는 사이트가 으로 사용할 수 있다는 것입니다 domain.comdomain.com/current

내가 어떻게 acc을 금지 할 수 있습니까? 에 current 디렉토리를 통해?

가장 좋은 해결책은 URL에 current이없는 동일한 페이지로의 외부 리디렉션입니다. URL에 현재 디렉토리가없는 사이트로 리다이렉션을 만들려면 어떻게해야합니까? > domain.com

  • domain.com/current/example - -> domain.com/example

    • domain.com/current :

      그래서 모든 URL은 다음과 같이 rewriten (외부)를 얻을
    • domain.com/current/what/ever/ -> domain.com/what/ever

    나는이 대답 발견 지금까지 : Url rewrite subfolder to root and forbid accessing subfolder합니다. 솔루션은 내 경우에는 작동하지 않는 것 같습니다. 이 솔루션을 사용하여 페이지에 액세스하면 오류 문서를 찾을 수 없으므로 403 오류 및 aditional 오류 500가 표시됩니다.

  • 답변

    1

    현재 디렉토리를 통한 액세스를 어떻게 금지 할 수 있습니까?

    # if direct request is made for /current/abc then external redirect to /abc 
    RewriteCond %{THE_REQUEST} \s/current/(\S*) [NC] 
    RewriteRule^/%1 [L,R=301,NE] 
    
    • THE_REQUEST 변수가 브라우저에서 아파치받은 원래의 요청을 나타내며, 그것은 몇 가지 재 작성 규칙의 실행 후 덮어하지 않습니다

    /current/.htaccess에 매우 첫 번째 규칙 등이 규칙을 삽입 .

  • 이 규칙은 사용자가 /current/ URI에 대한 직접 요청을 보내지 못하게합니다.
  • +0

    예. 하지만이 내 질문에 언급 한 것과 동일한 솔루션 및 나에게 추가 500 오류 403 제공합니다. Appache가 다음을 반환합니다 : 금지됨이 서버에 액세스 할 수있는/현재/없음 권한이 없습니다. 또한 요청을 처리하기 위해 ErrorDocument를 사용하려고 시도하는 동안 500 내부 서버 오류 오류가 발생했습니다. – jrast

    +0

    ok'ErrorDocument 500' 행을 주석 처리하고'ErrorDocument 403 default' 행을 추가하십시오. – anubhava

    +0

    'ErrorDocument 403 default'를 추가하면 더 이상 오류 500이 표시되지 않습니다. 액세스 거부 대신 리디렉션하는 방법에 대한 제안 사항이 있습니까? – jrast

    관련 문제