Curing a Domain's Split Personality

18 June, 2024

Are you stymied by and www. ending up in different places, even though they should not? If your domain is on a server that uses Apache, and if you have access to the Apache directory (typically /etc/apache2), then it could be an easy fix. In the Apache available sites directory (/etc/apache2/sites-available) should be an entry for each domain hosted on the server. It's common to copy and paste an existing one domain as a template for another. Editing the file /etc/apache2/sites-enabled/ shows the following:


<VirtualHost *:80> ServerName
ServerAlias ServerAdmin webmaster@localhost

DocumentRoot /home/ayendesi/public_html/drupal/d6
<Directory /home/mydomain/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny allow from all

ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit, # alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined

It's the serveralias line that is the important one. This line instructs Apache to accept the alias as an alias for the domain name. Without it, the web server could send the user to the server root directory, which on my server would be /var/www. While you are checking settings, it could well be worth ensuring that the DNS settings for the domain contain an A or C record titled www that points to the same location as the domain record.

Login or Register to Comment!