在mod_rewrite的虚拟主机配置 [英] mod_rewrite in vhosts configuration

查看:119
本文介绍了在mod_rewrite的虚拟主机配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在虚拟主机的配置添加mod_rewrite的规则,但它不工作。
对于网站mysite.com我想重定向/ webmedia /的主页。

下面是我:

 <虚拟主机192.168.100.142:80>
    的ServerAdmin serveradmin@bbgi.com
    的DocumentRoot /家庭/ drupal_1
    服务器名mysite.com
    ServerAlias​​ www.mysite.com
    别名/电影/家庭/电影/
    错误日志/var/log/httpd/mysite.com_err_log
      的CustomLog /var/log/httpd/mysite.com_log特殊
    <目录为/ home / drupal_1>
      有FollowSymLinks包括ExecCGI
              所有的AllowOverride
              的DirectoryIndex index.html的index.php文件的index.htm      #重写规则#####################
      RewriteEngine叙述在
      重写规则^ / webmedia /(.*)/ [R = 301,L]
      #结束重写规则#################    < /目录>
    <目录为/ home /电影和GT;
      有FollowSymLinks包括ExecCGI
              所有的AllowOverride
              的DirectoryIndex index.html的index.php文件的index.htm
    < /目录>< /虚拟主机>


解决方案

如果您有mod_rewrite的加载这应该工作。

 <目录为/ home / drupal_1>
    有FollowSymLinks包括ExecCGI
    所有的AllowOverride
    的DirectoryIndex index.html的index.php文件的index.htm
< /目录>
<目录为/ home /电影和GT;
    有FollowSymLinks包括ExecCGI
    所有的AllowOverride
    的DirectoryIndex index.html的index.php文件的index.htm
< /目录>
<虚拟主机192.168.100.142:80>
    的ServerAdmin serveradmin@bbgi.com
    的DocumentRoot /家庭/ drupal_1
    服务器名mysite.com
    ServerAlias​​ www.mysite.com
    别名/电影/家庭/电影/
    错误日志/var/log/httpd/mysite.com_err_log
    的CustomLog /var/log/httpd/mysite.com_log特殊    #重写规则#####################
    RewriteEngine叙述在
    重写规则^ / webmedia /(.*)/ [R = 301,L]
    #结束重写规则#################
< /虚拟主机>

I'm trying to add mod_rewrite rules in the vhost config but it's not working. For the site "mysite.com" I want to redirect "/webmedia/" to the home page .

Here is what I have:

<VirtualHost 192.168.100.142:80>
    ServerAdmin serveradmin@bbgi.com
    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>

解决方案

This should work if you have mod_rewrite loaded.

<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 serveradmin@bbgi.com
    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>

这篇关于在mod_rewrite的虚拟主机配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆