Apache Alias 从另一个目录提供 /blog 服务

Apache Alias 从另一个目录提供 /blog 服务

我正在升级我们的网站,博客还没有完成,所以我希望以 www.mydomain.com/blog* 开头的所有内容都使用特定目录 (var/www/blog) 下的代码,其他所有内容都来自另一个目录 (var/www/default)。我有这个:

<VirtualHost *:443>
    ServerName www.mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot /var/www/default/
    AliasMatch "^/blog(.*)" "/var/www/blog"
    <Directory "/var/www/blog">
         RewriteEngine On
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteCond %{REQUEST_FILENAME} !-d
         RewriteRule . index.php [L]
    </Directory>
    <Directory />
        AllowOverride All
        Order allow,deny
        Allow from all
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{DOCUMENT_ROOT}/dist%{REQUEST_URI} -f
        RewriteRule . dist/%{REQUEST_URI} [L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{DOCUMENT_ROOT}/app%{REQUEST_URI} -f
        RewriteRule . app/%{REQUEST_URI} [L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule .* dist/main.php [L]
    </Directory>

这不起作用,正在无限重定向到:

/blog.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html

有任何想法吗 ?

答案1

而不是你的AliasMatch尝试

Alias /blog /var/www/blog
<Directory /var/www/blog/>
  #Options +FollowSymLinks 
  #or whatever others you want
  AllowOverride All
  <IfVersion >= 2.3>
    Require all granted
  </IfVersion> 
  <IfVersion < 2.3>
    Order allow,deny
    Allow from all
  </IfVersion>
</Directory>

相关内容