Apache 虚拟主机

Sco*_*ott 1 rewrite virtualhost apache-2.2

我正在寻找这样做

<VirtualHost *>
    ServerName myDomain.com
    DocumentRoot /var/www/myDomain

    <Directory /var/www/myDomain>
         Rewrite on
         RewriteRule ^blog/(.*)$ /var/www/myBlog/$1 [L]
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

所以 http://www.myDomain.com/blog/将从不同的目录读取文件。上面的方法不起作用,我怎么能在不移动文件的情况下做到这一点?

bri*_*gge 7

没有必要为此使用用户 mod_rewrite。 别名更适合。

# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
Alias /blog /var/www/myBlog
Run Code Online (Sandbox Code Playgroud)

如果您只想更改博客的设置,请添加位置指令

<Location /blog>
    Allowoverride All
</Location>
Run Code Online (Sandbox Code Playgroud)