简体   繁体   中英

Apache virtual hosts without domain names, how to set a default site

I've set the following up to serve 2 development sites from the same box without using domain names:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    Alias /projecta /var/www/projecta
    Alias /projectb /var/www/projectb

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
     </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

This works, but how do I direct requests for just the IP address, that is without a site name postfix, to a 'default' site?

You can use mod_rewrite to redirect to defult site.

RewriteEngine on
RewriteRule   ^/$  /projecta  [R]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM