Pregunta

Estoy interesado en, si puedo tener vhosts en Apache con nombres de dominio como: http://something.com/something o http:// {servidor-ip-direccional-aquí} / algo ?

Estoy usando Apache 2.2.20 en Ubuntu Server, ese es mi servidor de inicio y estoy probando algunas cosas aquí, no tengo ningún servidor DNS aquí y lo que tengo es solo una dirección IP pública y un nombre de dominio que se le adjunta desde Abra el servicio DNS.

Entonces, ¿qué hice:

  1. He creado nuevo archivo "Demo" en / etc / apache2 / sites-disponibles
  2. Pongo esto (en realidad se copia con modificaciones del archivo predeterminado):

    <VirtualHost *:80>
       ServerAdmin webmaster@localhost
       ServerName  {mydomain-here}/demo/
       DocumentRoot /vhosts/demo
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /vhosts/demo/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>
    
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    
    CustomLog ${APACHE_LOG_DIR}/access.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>
    

  3. creado enlace simbólico en / etc / apache2 / sites-habilitado / que apunta a / etc / apache2 / sites-disponibles / demo

  4. creado /vhosts/demo/index.html Archivo.

    y ahora lo que recibo es que cuando voy a {my-dominio} Voy a vhost que he creado, pero el problema es que el servidor me apunta en cualquier caso, no solo {My-Domain} / Demo qué Quiero.

    En conclusión, quiero que pueda crear diferentes hosts virtuales y adjuntarlos a diferentes URL, que tendrán la misma URL de base, por ejemplo, www.mydomain.com/vhost1, www.mydomain.com/vhost2, etc. < / p>

    ¿Es posible? Gracias :)

¿Fue útil?

Solución

To start, the reason why it goes there is ANY case is cause you have you have a *:80 setting for your virtual host, so if nothing matches the request it uses the first virtual host entry

If I understand what you are trying to do it appears like you might just want to alias each 'virtual host'

What you are trying to do isn't quite a virtual host (at least what a virtual host is supposed to do), but you might be able to accomplish it by using alias feature of apache

Alias /vhost1 /whatever/folder/your/vhost1/site/is/at
Alias /vhost2 /whatever/folder/your/vhost2/site/is/at

So now whatever domain you use e.g. http://whatever.com/vhost1 or http://whatever.com/vhost2 The both of em will appear as separate sites

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top