2014-09-24 3 views
-2

회사 웹 사이트에 몇 가지 문제가 있습니다. 모든 것은, 일주일 전에 우리의 내 사이트를 확인하지만에 대해 작업 한아파치 404 URL이 작동하지 않습니다.

enter image description here

: 같은

# Virtual site directory 
# 
# This script lets us make use of default 
# versions of files used in a typical site. 
# When a request on the site is made for a file 
# that doesn't exist, instead of a 404 we rewrite 
# the path to /_control/site/ 
# 
# Any file in the directory this script is in will 
# take precedence over this script, so this script 
# only comes into play if the file does not exist. 

# First, set up URL rewriting 
Options +FollowSymLinks 
RewriteEngine On 

# Add trailing slash for directories 
# TODO: fix if site not in root dir (e.g. DEV server) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !.+\.(php|js|css|gif|jpg|jpeg|png)$ [NC] 
RewriteCond %{REQUEST_URI} !.*/$ 
RewriteRule ^(.*)$ /$1/ [L,R=301] 

# This Apache mod_rewrite rule checks to see 
# if the requested file exists, if it doesn't 
# then we rewrite to the respective site location. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !^.*/_control/(admin|common).*$ 
RewriteCond %{REQUEST_FILENAME} !^.*/_control/site/.*$ 
RewriteRule ^(.*)$ site/$1 [L] 

내 응용 프로그램의 구조는 같습니다 내 동료는이 같은 _control 디렉토리 안에 .htaccess 파일을 떠났다. com/admin 및 404 페이지가 호스팅 회사의 웹 사이트로 리디렉션되기 시작했습니다. DaveG는 이미 문제의 첫 번째 부분 인 https://stackoverflow.com/a/26013322/1933380에 응답했으며 가상 디렉터리를 작동시킬 수있었습니다. 나는 아직도 404 페이지에 문제가있다. 나는 뭔가를 놓치고 있거나 실수를하고 있는가?

+1

.htaccess에 'ErrorDocument 404' 행이 표시되지 않습니다. 또한 존재하지 않는 파일이나 디렉토리가'site/$ 1'로 보내면 404 처리에 영향을 미칠 것입니다. – anubhava

답변

1

지금하고있는 일은 웹 서버에 존재하지 않는 페이지와 디렉토리를 다른 폴더 (_control)로 찾는 것입니다.

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !^.*/_control/(admin|common).*$ 
RewriteCond %{REQUEST_FILENAME} !^.*/_control/site/.*$ 
RewriteRule ^(.*)$ site/errhandler.php?file=$1 [L] 

및 위해 (사용자 지정 404 - 페이지를 표시 errhandler.php라는 파일을 만들 : 당신은이 문제를 해결하려면이 오타의, 존재하지 않는 페이지 등을위한 솔루션을 제공하지 않습니다, 당신은 사용할 수 있습니다 예) 데이터베이스 검색 등을 기반으로 가능한 대안을 제시합니다. $_GET['file']을 사용하여 원래 파일 이름을 표시 할 수 있습니다.

+0

내가 만든 오류 파일을 사용하지 않아서 내가 가진 코드 아래에이 코드를 사용하게되었습니다 :'ErrorDocument 404/site/error.php' 그리고 이제는 정상적으로 작동합니다. – vDog

관련 문제