我的域名是example.com沒有www。所以,如果我把www.example.com放在那裏,那麼它不起作用,但example.com的作品。所以我喜歡這個Apache永久重定向自動轉到www
<VirtualHost *:80>
ServerName example.com
ServerAdmin [email protected]
Redirect permanent/https://example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAdmin [email protected]
DocumentRoot path/to/project/public
SSLEngine on
SSLCertificateFile /path/to/keys/xxx.crt
SSLCertificateKeyFile /path/to/keys/xxx.key
ErrorLog /var/log/apache2/error_log
CustomLog /var/log/apache2/access_log combined
<Directory "path/to/project/public">
Options FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
配置阿帕奇現在,你可以看到,我做一個永久重定向到HTTPS像
Redirect permanent/https://example.com/
但是這種重定向加上www用默認的域名。所以重定向的url變成了https://www.example.com/
。很明顯,我的網站無法從www訪問,因爲它是在沒有www的情況下注冊的。所以請告訴我如何使重定向工作,並在沒有https的情況下去https://example.com/
。