将虚拟主机内的文件夹映射到另一个虚拟主机

将虚拟主机内的文件夹映射到另一个虚拟主机

我有一个网站 domain.com,其文档根目录中有一个媒体文件夹。我想创建 media.domain.com,它将解析到“media”文件夹。

这是我当前的 vhost 配置。

<VirtualHost *:80>
    ServerName domain.com
    DocumentRoot /var/www/domain.com
    <Directory /var/www/domain.com>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

</VirtualHost>



<VirtualHost *:80>
        ServerName media.domain.com

        DocumentRoot /var/www/domain.com/media/

        php_admin_value engine off
        ExpiresActive On

        <Directory /var/www/domain.com/media/>
                # Options -Indexes
                # AllowOverride All
                ExpiresDefault A2592000
                ExpiresByType image/jpg "access plus 10 months"
                ExpiresByType image/jpeg "access plus 10 months"
                Require all granted
        </Directory>
</VirtualHost>

问题是 domain.com 可以运行,但是访问 media.domain.com 时出现错误 500,错误如下:

[Thu May 12 14:23:45.190243 2016] [core:alert] [pid 17350] [client 89.111.111.11:52178] /var/www/domain.com/.htaccess: RewriteEngine not allowed here, referer: http://media.domain.com/5697c88947f54_400.jpg

以下是 .htaccess 的内容:

RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>

RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Protect .SVN folder
RewriteRule ^(.*/)*\.svn/ / [F,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT]

谢谢你!

相关内容