2014-10-12 2 views
0

내 htaccess는 기존의 페이지가 아닌 올바른 사용자 정의 404 페이지를 표시하지만 domain.com/existingdirectory과 같은 색인 파일이없는 디렉토리의 경우 기본값이 아닌 사용자 정의 내부 오류 페이지. 문제는 어디에 있는지 파악하십시오..htaccess는 기존 URL이 아닌 기존 URL에 대해 404 페이지를 표시합니다.

ErrorDocument 400 /404.php 
ErrorDocument 403 /404.php 
ErrorDocument 408 /404.php 
ErrorDocument 500 /404.php 
ErrorDocument 404 /404.php 

<IfModule mod_headers.c> 
    Header set X-Content-Type-Options "nosniff" 
</IfModule> 

<Files .htaccess> 
    Order Allow,Deny 
    Deny from all 
</Files> 

Options All -Indexes 
<IfModule mod_autoindex.c> 
    Options -Indexes 
</IfModule> 

<IfModule mod_deflate.c> 
    <IfModule mod_setenvif.c> 
     <IfModule mod_headers.c> 
      SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding 
      RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding 
     </IfModule> 
    </IfModule> 
    <IfModule mod_filter.c> 
     AddOutputFilterByType DEFLATE application/atom+xml \ 
             application/javascript \ 
             application/json \ 
             application/rss+xml \ 
             application/vnd.ms-fontobject \ 
             application/x-font-ttf \ 
             application/x-web-app-manifest+json \ 
             application/xhtml+xml \ 
             application/xml \ 
             font/opentype \ 
             image/svg+xml \ 
             image/x-icon \ 
             text/css \ 
             text/html \ 
             text/plain \ 
             text/x-component \ 
             text/xml 
             application/ld+json \ 
             application/manifest+json \ 
             text/vtt \ 
BrowserMatch ^Mozilla/4 gzip-only-text/html 
BrowserMatch ^Mozilla/4\.0[678] no-gzip 
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 
Header append Vary User-Agent 
    </IfModule> 
</IfModule> 

<IfModule mod_expires.c> 
    ExpiresActive on 
    ExpiresDefault          "access plus 1 month" 
    ExpiresByType text/css        "access plus 1 year" 
    ExpiresByType application/json      "access plus 0 seconds" 
    ExpiresByType application/xml      "access plus 0 seconds" 
    ExpiresByType text/xml        "access plus 0 seconds" 
    ExpiresByType image/x-icon       "access plus 1 week" 
    ExpiresByType text/x-component      "access plus 1 month" 
    ExpiresByType text/html        "access plus 0 seconds" 
    ExpiresByType application/javascript    "access plus 1 year" 
    ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" 
    ExpiresByType text/cache-manifest     "access plus 0 seconds" 
    ExpiresByType audio/ogg        "access plus 1 month" 
    ExpiresByType image/gif        "access plus 1 month" 
    ExpiresByType image/jpeg       "access plus 1 month" 
    ExpiresByType image/png        "access plus 1 month" 
    ExpiresByType video/mp4        "access plus 1 month" 
    ExpiresByType video/ogg        "access plus 1 month" 
    ExpiresByType video/webm       "access plus 1 month" 
    ExpiresByType application/atom+xml     "access plus 1 hour" 
    ExpiresByType application/rss+xml     "access plus 1 hour" 
    ExpiresByType application/font-woff     "access plus 1 month" 
    ExpiresByType application/font-woff2    "access plus 1 month" 
    ExpiresByType application/vnd.ms-fontobject   "access plus 1 month" 
    ExpiresByType application/x-font-ttf    "access plus 1 month" 
    ExpiresByType font/opentype       "access plus 1 month" 
    ExpiresByType image/svg+xml       "access plus 1 month" 
    ExpiresByType image/jpg        "access plus 1 month" 
    ExpiresByType font/truetype       "access plus 1 month" 
    ExpiresByType text/javascript      "access plus 1 year" 

     <IfModule mod_headers.c> 
     Header append Cache-Control "public" 
     </IfModule> 
</IfModule> 

답변

1

403 메시지도 덮어 씁니다.

ErrorDocument 403 /404.php 

이유는 확실하지가 mod_rewrite 블록의 내부이고 할 이유가 재 작성 엔진을 사용하려면. 사용자 지정 오류 페이지

<IfModule mod_rewrite.c> # remove this line 
    RewriteEngine On # remove 
    RewriteBase/#remove 
    ..... # keep the list of ErrorDocument, but remove everything else. 
</IfModule> # and also remove this line 

당신이 http://httpd.apache.org/docs/2.2/mod/core.html#errordocument에서 볼 수 있듯이 아래의 부분이 필요하지 않습니다 - 그것은 핵심의 기능, 그것은 다른 모듈에 대한 검진이 필요하지 않도록. 이 블록 대신 최종 코드는 다음과 같이 표시됩니다.

ErrorDocument 400 /404.php 
ErrorDocument 403 /404.php 
ErrorDocument 408 /404.php 
ErrorDocument 500 /404.php 
ErrorDocument 404 /404.php 
+0

정말 죄송합니다. 'RewriteEngine On RewriteBase /'는 이제 파일이 없습니다. 분명히 문제가 해결되었습니다. 그러나 내가 새로 왔기 때문에'RewriteEngine On RewriteBase /'를 완전히 제거하시오. – XIMRX

+0

@XIMRX 예,'modModule' 조건을'mod_rewrite'를 사용하지 않으므로'ErrorDocument' 지시자가 필요 없습니다. 이 모듈과 관련이 없습니다. – Cheery

+0

고마워. 그리고 나와 미래의 방문자를 도울 수있는 다른 오류를 지적 해 줄 수 있니? – XIMRX

관련 문제