On my VDS with Ubuntu 16.04 there is an SSL certificate only on site.ru. I want to make a blog.site.ru subdomain, which SSL doesn’t apply to, added it in the config'i, however when switching to a subdomain it uses project pages from the main domain. Must use / var / www / blog, but use as the main one / / var / www / site Both folders are different Laravel-5.5 projects

000-default.conf:

<VirtualHost *:80> ServerAdmin 123@gmail.com DocumentRoot /var/www/site/public/ ServerName site.ru ServerAlias www.site.ru <Directory /var/www/site/public> Allowoverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

blog.conf:

 <VirtualHost *:80> ServerAdmin 123@gmail.com DocumentRoot /var/www/blog/public/ ServerName blog.site.ru ServerAlias www.blog.site.ru <Directory /var/www/blog/public> Allowoverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

default-ssl.conf:

 <IfModule mod_ssl.c> <VirtualHost *:443> ServerAdmin 123@gmail.com DocumentRoot /var/www/site/public/ ServerName site.ru ServerAlias www.site.ru SSLEngine on SSLCertificateFile /SSL/domain_name.crt SSLCertificateKeyFile /SSL/private.key SSLCertificateChainFile /SSL/chain.crt ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory /var/www/site/public> Allowoverride All Require all granted </Directory> </VirtualHost> </IfModule> 

ports.conf:

 Listen 80 <IfModule ssl_module> Listen 443 </IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule> 

Project .htaccess file / var / www / site

 <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # http -> https RewriteCond %{HTTPS} !on RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ # RewriteRule ^ %1 [L,R=301] RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> 

apache2.conf:

 Mutex file:${APACHE_LOCK_DIR} default PidFile ${APACHE_PID_FILE} Timeout 300 KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 5 User ${APACHE_RUN_USER} Group ${APACHE_RUN_GROUP} HostnameLookups Off ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn IncludeOptional mods-enabled/*.load IncludeOptional mods-enabled/*.conf Include ports.conf <Directory /> Options FollowSymLinks AllowOverride None Require all denied </Directory> <Directory /usr/share> AllowOverride None Require all granted </Directory> <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> AccessFileName .htaccess <FilesMatch "^\.ht"> Require all denied </FilesMatch> LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User- Agent}i\"" vhost_combined LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %O" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent IncludeOptional conf-enabled/*.conf IncludeOptional sites-enabled/*.conf 
  • So what exactly is the problem? What is not created? - de_frag
  • @defrag when going through the url of a subdomain uses project pages from the main domain. Must open the project / var / www / blog, and opens / var / www / site - badordos
  • Apache itself does not redirect anything anywhere. In the config about this not a word. If you log into your subdomain exactly as "http", and not "https", it should work. If you find yourself on the page https: main-site, then you have to redirect to some of your subdomain files - Mike
  • @Mike That's exactly what I find myself on http: blog.site.ru, but for an unclear reason, I use the / var / www / site project, not the blog, although I specified correctly in the config folder - badordos
  • It turns out the virtual host does not work at all. look where and how other hosts on port 80 are described. in the config you have given, there is no such thing at all, it means they are described in some other config - Mike

1 answer 1

Perhaps you have Nginx installed as a proxy for Apache, in which case you also need to add a new host configuration file for it. Just try to play with the ports, in the settings of the virtual hosts. I do not think it is connected with SSL. Well, or problems in the DNS records.

  • Nginx is not installed. In dns records there is a rule that sends all * .site.ru to the host ip. And what can be done with the ports? If you change them - the pages will become unavailable. - badordos