
我用 apache2.4(debian) 建置了兩個虛擬主機。
cat /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerName www.hwy.local
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error_hwy.log
CustomLog ${APACHE_LOG_DIR}/access_hwy.log combined
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.test.app
ServerAdmin webmaster@localhost
DocumentRoot /home/debian9/app
ErrorLog ${APACHE_LOG_DIR}/error_hwy.log
CustomLog ${APACHE_LOG_DIR}/access_hwy.log combined
<Directory /home/debian9/app>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
打字www.hwy.local
不會重定向https://www.hwy.local
,打字www.test.app
會重定向https://www.test.app
,為什麼?
答案1
根據 Michael Hampton 的說法,www.test.app 的重定向不是來自 apache 設定文件,應用程式的根目錄中是否有 .htaccess 檔案?可以配置重定向!