2012-04-16 26 views
9

मैं vhost config में mod_rewrite नियम जोड़ने की कोशिश कर रहा हूं लेकिन यह काम नहीं कर रहा है। साइट "mysite.com" साइट के लिए मैं होम पेज पर "/ webmedia /" को रीडायरेक्ट करना चाहता हूं।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' फाइल करने के लिए अपने नियम नहीं चलती? यह प्रबंधित करना अधिक आसान होगा क्योंकि आपके द्वारा किए गए प्रत्येक संशोधन के बाद आपको अपाचे को पुनरारंभ करने की आवश्यकता नहीं होगी। –

+2

.htaccess फ़ाइल बड़ी हो रही है और मैंने सुना है कि सर्वर को vhosts फ़ाइल से इसे पढ़ने के लिए यह अधिक कुशल है। क्या वो सही है? – EricP

+2

हां, अपाचे शायद 'faster_ को अनुमति दें' बिना अनुमति दें क्योंकि इसे प्रत्येक अनुरोध पर आपकी .htaccess फ़ाइल को पढ़ने की आवश्यकता नहीं है। मुझे लगता है कि प्रदर्शन का लाभ यहां _very_ छोटा है। इसके लिए आपके पास 'htaccess' में वर्तमान में क्या है? –

उत्तर

11

अगर आप mod_rewrite लोड काम करना चाहिए:

यहाँ मैं क्या है।

<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

धन्यवाद सेबसेन। वह यह था। – EricP

+0

यदि सर्वर .htaccess फ़ाइलों में कम पुनर्लेखन है और vhost config में अधिक है तो सर्वर पर मैं आसान है? या यह कोई महत्त्व नहीं रखता? – EricP

+1

इस उत्तर को देखें: http://stackoverflow.com/a/9555416/982002 – Seybsen