Domain doesn't work without `www`

前端 未结 6 1040
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 07:31

When I type in my domain name like without the www (like http://example.com), it doesn\'t work and gives error message. However, when I add the

6条回答
  •  执笔经年
    2020-12-14 07:44

    With the current version of apache, you need to do the following, which has changed compared to the previous versions:

    cd /etc/apache2/sites-enabled
    

    Now find the config file for your domain and edit it (the first three lines after is what we need here):

    
            ServerName www.yourdomain.com
            ServerAlias yourdomain.com *.yourdomain.com
            ServerAdmin webmaster@localhost
    
            
                    Options FollowSymLinks
                    AllowOverride None
            
    
    
    

    And now after saving changes to the file, you should reload Apache we server configuration with:

    service apache2 reload
    

    and it'll work!

    P.S. You may also want not to add *.yourdomain.com to the end of your ServerAlias line.

提交回复
热议问题