通过www访问域。重定向到子域

时间:2019-12-10 12:18:07

标签: redirect apache2 subdomain virtual hosts

我的网站有问题。通过https://website.com访问时,一切正常,但通过www.website.com访问时,它将重定向到子域。

主域虚拟主机文件:

<VirtualHost *:8080>
ServerAdmin contact@website.com
DocumentRoot /var/www/html/website/
ServerName website.com
ServerAlias www.website.com

<Directory /var/www/html/website/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
ServerName hwebsite.com
ServerAlias www.website.com
DocumentRoot /var/www/html/website/

ProxyPreserveHost on
ProxyPass / http://127.0.0.1:8080/
RequestHeader set X-Forwarded-Port "443"
RequestHeader set X-Forwarded-Proto "https"

SSLEngine On
SSLCertificateFile /etc/ssl/certs/website.com.crt
SSLCertificateKeyFile /etc/ssl/private-key.pem
SSLCertificateChainFile /etc/ssl/website.com.ca-bundle
 <Directory /var/www/html/website/>
 Options Indexes FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
</Directory>
</VirtualHost>

子域虚拟主机文件:

<VirtualHost *:80>
ServerAdmin contact@website.com
DocumentRoot /var/www/subdomains/sub.website.com/
ServerName sub.website.com
ServerAlias www.sub.website.com

<Directory /var/www/subdomains/sub.website.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
ServerName sub.website.com
ServerAlias www.sub.website.com
DocumentRoot /var/www/subdomains/sub.website.com/

ProxyPreserveHost on
ProxyPass / http://localhost:80/
RequestHeader set X-Forwarded-Port "443"
RequestHeader set X-Forwarded-Proto "https"

SSLEngine On
SSLCertificateFile /etc/ssl/certs/sub.website.com.crt
SSLCertificateKeyFile /etc/ssl/private/sub.website.com.key
<Directory /var/www/subdomains/sub.website.com/>
Options Indexes FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

如果有人可以阐明一点,将不胜感激。

关于, Cristi Enache

0 个答案:

没有答案