[Apache 2] 從 domain.name 重定向至 www.domain.name

  1. sudo nano /etc/apache2/sites-available/000-default.conf
    <VirtualHost *:80>
      ServerName domain.name
      Redirect permanent / http://www.domain.name/
    </VirtualHost>
    
    <VirtualHost *:80>
      ServerName www.domain.name
      # real server configuration
      ...
    </VirtualHost>
  2. sudo apachectl configtest → Syntax OK

    如果沒有sudo 可能因為權限不足無法存取
    而出現 AH00526
    SSLCertificateFile: file ‘/etc/letsencrypt/live/a1go.ai/fullchain.pem’ does not exist or is empty

  3. sudo systemctl restart apache2

 

Last Updated on 2023/10/24 by A1go

Bitnami