![Apache Alias 从另一个目录提供 /blog 服务](https://linux22.com/image/702353/Apache%20Alias%20%E4%BB%8E%E5%8F%A6%E4%B8%80%E4%B8%AA%E7%9B%AE%E5%BD%95%E6%8F%90%E4%BE%9B%20%2Fblog%20%E6%9C%8D%E5%8A%A1.png)
我正在升级我们的网站,博客还没有完成,所以我希望以 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>