Skip to content

Instantly share code, notes, and snippets.

@lav45
Last active August 29, 2015 14:06
Show Gist options
  • Save lav45/86f5955de622544d760f to your computer and use it in GitHub Desktop.
Save lav45/86f5955de622544d760f to your computer and use it in GitHub Desktop.
Apache VirtualDocumentRoot
ServerName localhost
AddDefaultCharset utf-8
AddType application/x-httpd-php .php .phtml
DirectoryIndex index.html index.htm index.php
ServerAdmin webmaster@admin.my
DocumentRoot /var/www/my
<Directory /var/www/my>
Options FollowSymLInks SymLinksIfOwnerMatch MultiViews Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
CustomLog /dev/null vhost_combined
ErrorLog /var/log/apache2/error.log
LogLevel warn
ServerAlias *.my
VirtualDocumentRoot /var/www/my/%-2
</VirtualHost>
@lav45
Copy link
Author

lav45 commented Sep 23, 2014

VirtualDocumentRoot - позволяет без перезапуска Apache быстра создавать новые проекты с таким же именем как и имя папки.
Единственная проблема в переменной $_SERVER['DOCUMENT_ROOT'] будет находится путь /var/www/my

Таким образом при переходе по следующим ссылкам

http://site.my
http://www.site.my
http://admin.site.my

будет отображаться один и тот же сайт из /var/www/my/site

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment