2008-08-12 4 views
12

나는 .htaccessmod_rewrite을 사용하여 DocumentRoot 뒤에있는 파일을 가리 킵니다. 내 폴더 구조는 다음과 같습니다ModRewrite로 DocumentRoot 뒤에 파일 로딩

The requested URL /home/other_files/file.html was not found on this server.

: 나는 다음과 같은 오류가 발생 http://example.com/file.html에 액세스하려고하면

 
RewriteEngine on 
RewriteRule ^(.*)$ /home/other_files/$1 

:

home/ 
    webroot/ 
    other_files/ 

나는 다음과 같은 내용으로 웹 루트에 .htaccess 파일이

DocumentRoot 뒤에있는 파일을로드 할 수 있습니까? 그렇다면 누군가가 올바른 방향으로 나를 가리킬 수 있습니까?

답변

11

난 당신이 아파치 그것에서 어떤 역할을 할 수있을 것입니다 전에 서버 구성에

<Directory "/home/other_files"> 
    (options) 
</Directory> 

에 섹션을 추가해야합니다 생각합니다. 예를 들어, 내을 DocumentRoot는/var에/www가 있지만 기본적 가능한 사이트에서이 섹션이 있습니다 : 당신은 다음 URL을 다시 쓸 수

Alias /doc/ "/usr/share/doc/" 
<Directory "/usr/share/doc/"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride None 
    Order deny,allow 
    Deny from all 
    Allow from 127.0.0.0/255.0.0.0 ::1/128 
</Directory> 

이/문서에 갈 /과를 얻을 경우 서버가 알고있는 것은 에서 파일. 그 규칙이 작동하지 않습니다 왜 그냥 알다시피

+0

좋은 대답! 고마워요 –

+0

섹션없이 DocumentRoot 외부의 디렉토리에 별칭을 시도했는데 성공했습니다 ... – Pere

0

:

/home/other\_files/file.html에 다시 할 수없는 이유는 그 mod_rewrite를보기의 mod_rewrite는의 관점 앞 슬래시 가입일 /home/webroot/home/other\_files/file.html 같은 경로를 분석입니다 문서 루트 /home/webroot에 해당합니다.

Ryan Ahearn's suggestion은 괜찮은 경로이며 가고자하는 경로입니다.

0

신용은 Ryan Aheam에게 돌아갑니다. 그러나 나는 그것을 철자하겠습니다. 나는 초보자이고 라이언의 대답조차도 구문을 올바로 사용하기 위해 몇 가지 사항을 실험해야했습니다.

저는 내 DocumentRoot를 내 cakephp 디렉토리로 원했습니다. 하지만 난 그냥 정기적으로 PHP와 너무 cakephp 디렉토리에 없었던 Mantis 버그 추적기를했다. 아래의 파일들은 다음과 같습니다.

http://www.my_website.com :의/var/www /에서 CakePHP의에 의해 제공

http://www.my_website.com/mantisbt :에 의해 제공의/var/www/html/mantisbt

파일

Alias /mantisbt/ "/var/www/html/mantisbt/"                   
<Directory "/var/www/html/">                       
    AllowOverride All                        
</Directory>                           

<VirtualHost *:80>                         
    ServerAdmin [email protected]_email.com                    
    DocumentRoot /var/www/cakephp                     
    ServerName my_website.com                      
    <Directory /var/www/cakephp/>                     
     AllowOverride All                       
    </Directory>                          
</VirtualHost> 
/etc/httpd/conf/httpd.conf 파일

파일 /var/www/cakephp/.htaccess

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteRule ^mantisbt/?$ /mantisbt/ [NC,L] 
    RewriteRule ^$ webroot/ [L] 
    RewriteRule (.*) webroot/$1 [L] 
</IfModule>