如果我选择http://example.com
,则指向/var/www/html
现在我需要的是,如果我选择http://example.com/dashboard
,那么它会指向/var/www/example/public
。或者如果这不可能,那么/var/www/html/example/public
也可以。
我再次需要,如果我选择http://wildcardsubdomain.example.com/
,那么它也会指向/var/www/example/public
。或者如果这不可能,那么/var/www/html/example/public
也可以。
我怎么能这样做?
我试过这个,但/dashboard
无法正常工作:
ServerName example.com
# Listen for virtual host requests on all IP addresses
UseCanonicalName Off
#dynamic subdomain provisioning
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
#WORKING
ServerName user.example.com
ServerAlias *.example.com
DocumentRoot /var/www/example/public
</VirtualHost>
<VirtualHost *:80>
#NOT WORKING
ServerName www.example.com/dashboard
ServerAlias *.example.com/dashboard
DocumentRoot /var/www/example/public
</VirtualHost>
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
答案 0 :(得分:0)
对于dashboard
我可以使用Alias Directive
<VirtualHost *:80>
DocumentRoot /var/www/html
Alias /dashboard /var/www/example/public
<Directory /var/www/example/public>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>