Вопрос

Я заинтересован, если у меня может быть VHOSTS на Apache с доменными именами, такими как: http://something.com/something или http:// {сервер-IP-адрес - здесь} / что-то ?

Я использую Apache 2.2.20 на сервере ubuntu, это мой домашний сервер, и я проверяю здесь некоторые вещи, у меня здесь нет ни одного DNS-сервера, и то, что у меня есть только общедоступный IP-адрес, и имя доменного имени, от Откройте DNS-сервис.

Так, что я сделал:

  1. Я создал новый файл "Demo" в / ETC / APACHE2 / Доступных сайтов
  2. Я положил туда это (на самом деле он скопирован с модификациями файла по умолчанию):

    <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. создал symlink в / etc / apache2 / sites-eniled / какие точки к / etc / apache2 / fitsies / demo demo

  4. создал /vhosts/demo/index.html файл.

    И теперь, что я получаю, это то, что когда я иду в {my-domain} Я иду в Vhost, который я создал, но проблема в том, что сервер указывает мне там в любом случае, не только {my-domain} / demo, что Я хочу.

    В заключение я хочу, чтобы я мог создавать разные виртуальные хосты и прикрепить их к разным URL-адресам, который будет иметь тот же базовый URL, например www.mydomain.com/vhost1, www.mydomain.com/vhost2 и т. Д. / P >.

    Это возможно? Спасибо :)

Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top