我的 webroot 中有两个应用程序,
/var/www/mysite
/var/www/blog
我想要访问我的网站http://mysite.com
类似应用博客 应用程序http://mysite.com/blog
。我正在本地尝试此设置,因此,我已更新主办方文件如下行。
127.0.0.1 mysite.com www.mysite.com
127.0.0.1 mysite.com/blog www.mysite.com/blog # May be looks somewhat foolish with this line
我已经为我的网站应用程序DocumentRoot
并/var/www/mysite
能够访问它,但我不明白是否需要为博客应用程序或我需要修改现有的我的网站虚拟主机文件?
以下是我的网站应用程序虚拟主机文件,
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName www.mysite.com
ServerAlias myssite.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L]
DocumentRoot /var/www/mysite
<Directory />
Options None
Order deny,allow
allow from all
</Directory>
<Directory /var/www/mysite>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SetEnvIf Host (.*) custom_host=$1
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error-mysite.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access-mysite.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
答案1
我认为你不需要为博客单独设置虚拟主机。你只需要使用别名
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName www.mysite.com
ServerAlias myssite.com
DocumentRoot /var/www/mysite
Alias /blog /var/www/blog
<Directory /var/www/mysite>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/blog>
...
</Directory>
</VirtualHost>