I have following virtual host ( in apache2.conf file ) to load all subdomain from a single directory on AWS
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName mydevsite.com
ServerAlias mydevsite.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/apps
ServerName mydevsite.com
ServerAlias *.mydevsite.com
</VirtualHost>
It not working and subdomains are still pointing to html directory
I tried following in htaccess as well but then it gives me 500 error
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteCond %{HTTP_HOST} ^(\w+)\.website\.com$
RewriteCond %{REQUEST_URI}:%1 !^/([^/]+)/([^:]*):\1
RewriteRule ^(.*)$ /%1/$1 [QSA]
My simple requirement is to load main domain from root directory and all subdomains from apps directory
Check the Doc: Using Name-based Virtual Hosts , ServerName Directive , ServerAlias Directive
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName www.mydevsite.com
ServerAlias mydevsite.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/apps
ServerName apps.mydevsite.com
ServerAlias *.mydevsite.com
</VirtualHost>
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.