2012-04-16 2 views
9

vhost 구성에 mod_rewrite 규칙을 추가하려고하는데 작동하지 않습니다. "mysite.com"사이트의 경우 "/ webmedia /"를 홈 페이지로 리디렉션하고 싶습니다. 당신이 mod_rewrite를로드있는 경우에 작동합니다vhosts 구성의 mod_rewrite

<VirtualHost 192.168.100.142:80> 
    ServerAdmin [email protected] 
    DocumentRoot /home/drupal_1 
    ServerName mysite.com 
    ServerAlias www.mysite.com 
    Alias /movies /home/movies/ 
    ErrorLog /var/log/httpd/mysite.com_err_log 
     CustomLog /var/log/httpd/mysite.com_log special 
    <Directory /home/drupal_1> 
     Options FollowSymLinks Includes ExecCGI 
       AllowOverride All 
       DirectoryIndex index.html index.htm index.php 

     # Rewrite Rules ##################### 
     RewriteEngine On 
     RewriteRule ^/webmedia/(.*)/[R=301,L] 
     # end Rewrite Rules ################# 

    </Directory> 
    <Directory /home/movies> 
     Options FollowSymLinks Includes ExecCGI 
       AllowOverride All 
       DirectoryIndex index.html index.htm index.php 
    </Directory> 

</VirtualHost> 
+0

왜 규칙을'.htaccess' 파일로 옮기지 않으시겠습니까? 모든 수정 후에 Apache를 다시 시작할 필요가 없으므로 관리가 훨씬 쉬워집니다. –

+2

.htaccess 파일이 커지고 있고 서버가 vhosts 파일에서 그것을 읽는 것이 더 효율적이라고 들었습니다. 그 맞습니까? – EricP

+2

예, Apache는 모든 요청에 ​​대해 .htaccess 파일을 읽을 필요가 없으므로 'AllowOverride All'없이 _faster_입니다. 퍼포먼스의 이득은 여기서 매우 작다고 생각합니다. 그것이 당신의'.htaccess'에서 현재 가지고있는 것은 무엇입니까? –

답변

11

: 여기

내가 가진 것입니다.

<Directory /home/drupal_1> 
    Options FollowSymLinks Includes ExecCGI 
    AllowOverride All 
    DirectoryIndex index.html index.htm index.php 
</Directory> 
<Directory /home/movies> 
    Options FollowSymLinks Includes ExecCGI 
    AllowOverride All 
    DirectoryIndex index.html index.htm index.php 
</Directory> 
<VirtualHost 192.168.100.142:80> 
    ServerAdmin [email protected] 
    DocumentRoot /home/drupal_1 
    ServerName mysite.com 
    ServerAlias www.mysite.com 
    Alias /movies /home/movies/ 
    ErrorLog /var/log/httpd/mysite.com_err_log 
    CustomLog /var/log/httpd/mysite.com_log special 

    # Rewrite Rules ##################### 
    RewriteEngine On 
    RewriteRule ^/webmedia/(.*)/[R=301,L] 
    # end Rewrite Rules ################# 
</VirtualHost> 
+0

Seybsen에 감사드립니다. 그거였다. – EricP

+0

.htaccess 파일에 더 적은 재기록이 있고 vhost 설정이 더 많으면 서버에서 더 쉽습니다. 또는 그것은 중요하지 않습니까? – EricP

+1

이 답변을보십시오 : http://stackoverflow.com/a/9555416/982002 – Seybsen