I have a Ubuntu 10.04 LTS VPS with complete access and some Wordpress installations mounted. Current Apache2 version is 2.2.14-5ubuntu8.7 and the mod-php5 is 5.3.2-1ubuntu4.10. FWIW.
The vhosts file for a typical site is:
<VirtualHost *:80>
ServerAdmin webmaster@mydomain.com
DocumentRoot /home/myuser/www/mydomain.com
ServerName mydomain.com
CustomLog /home/myuser/logs/mydomain.com/access_log combined
ErrorLog /home/myuser/logs/mydomain.com/error_log
<DIRECTORY /home/myuser/www/mydomain.com >
OPTIONS FollowSymLinks
AllowOverride All
</DIRECTORY>
IndexOptions FancyIndexing
</VirtualHost>
<VirtualHost *:80>
ServerName www.mydomain.com
RedirectMatch permanent ^/(.*) http://mydomain.com/$1
</VirtualHost>
So this has a proper 301 redirect.
For some sites it is, I just used ServerAlias:
<VirtualHost *:80>
ServerAdmin webmaster@mydomain.com
DocumentRoot /home/myuser/www/mydomain.com
ServerName mydomain.com
ServerAlias www.mydomain.com
CustomLog /home/myuser/logs/mydomain.com/access_log combined env=!loopback
ErrorLog /home/myuser/logs/mydomain.com/error_log
<DIRECTORY /home/myuser/www/mydomain.com >
OPTIONS FollowSymLinks
AllowOverride All
</DIRECTORY>
IndexOptions FancyIndexing
</VirtualHost>
The .htaccess is set to:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I have only the following modules enabled:
LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so
LoadModule auth_basic_module /usr/lib/apache2/modules/mod_auth_basic.so
LoadModule authn_file_module /usr/lib/apache2/modules/mod_authn_file.so
LoadModule authz_groupfile_module /usr/lib/apache2/modules/mod_authz_groupfile.so
LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so
LoadModule authz_user_module /usr/lib/apache2/modules/mod_authz_user.so
LoadModule autoindex_module /usr/lib/apache2/modules/mod_autoindex.so
LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
LoadModule dir_module /usr/lib/apache2/modules/mod_dir.so
LoadModule expires_module /usr/lib/apache2/modules/mod_expires.so
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
LoadModule mime_module /usr/lib/apache2/modules/mod_mime.so
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
LoadModule setenvif_module /usr/lib/apache2/modules/mod_setenvif.so
LoadModule status_module /usr/lib/apache2/modules/mod_status.so
In both cases the URL is set in Wordpress
without the www. prefix and, as you see, the ServerName does not include the www but is aliased in one of two ways to the www.mydomain.com.
This all works hunky dory but I am trying to optimise the server and also tune the sites.
Because when I try httping, which as I understand it does test the page generation etc, I get very different results. For the first setup, it is substantially faster when httping the www-version by a factor of about 4. For the second setup, there appears to be no difference.
My questions to the assembled multitude are:
1) Is there a reason outside my settings why apache should return better figures for the www version than the non-www version? I can't believe there is as the www is only a convention devised I assume by Sir Tim and is just a sub-domain.
2) Is it possible that httping is just reporting the latency to the redirect stage rather than building the page? Ping is substantially quicker though at about 1/3rd the faster time.
3) Is there a general SEO recommendation whether to include www or not? I have added the appropriate AddIgnoredRef to Google Analytics in one case but that is only interesting for reporting reasons. Obviously I want the search engines to regard the site and canoncial versions as the same.
Hopefully you have understood my garbled message ;-)