我在 VPS 上使用 Ubuntu 16.04 创建了一个网站。在 DNS 中,IP 地址与我的域名相连。当我在浏览器的地址栏中输入域名时,域名会更改为 IP 地址。网站将显示。
如何设置虚拟主机以便域名保留在地址栏中?
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/www.domain.nl/public_html
ServerAlias www.domain.nl
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot /var/www/www.domain.nl/public_html
SSLEngine on
SSLCertificateFile /usr/share/ca-certificates/domain.nl/domain.crt
SSLCertificateKeyFile /usr/share/ca-certificates/domain.nl/domain.key
SSLCertificateChainFile /usr/share/ca-certificates/domain.nl/DigiCertCA.crt
ServerName domain.nl
ServerAlias www.domain.nl
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#RewriteEngine on
#RewriteCond %{SERVER_NAME} =domain.nl [OR]
#RewriteCond %{SERVER_NAME} =www.domain.nl
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
最后的备注是启用SSL证书,但是我必须在解决这个问题后才这么做。
诚挚问候,Guido