virtual host setup: can't access wordpress site without www

Posted by two7s_clash on Server Fault See other posts from Server Fault or by two7s_clash
Published on 2012-03-25T14:44:26Z Indexed on 2012/03/25 17:31 UTC
Read the original article Hit count: 341

I would like to access my site both with and without using the www. Currently it only works with. Leaving out the www just goes to a blank page. Also, wp-admin just loads a blank page too.

I have set an A record for mysite.com and www.mysite.com, both pointing to my static Bitnami IP. I also have a subdomain mapped to another directory that is working just fine (conference.mysite.com and www.conference.mysite.com).

I'm using a Bitnami stack on an AWS EC2 micro instance.

Here is my httpd.conf:

ServerRoot "/opt/bitnami/apache2"
Listen 80

LoadModule authn_file_module modules/mod_authn_file.so
blah blah blah....
LoadModule php5_module        modules/libphp5.so

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
User daemon
Group daemon
</IfModule>
</IfModule>

ServerAdmin [email protected]
ServerName localhost:80
DocumentRoot "/opt/bitnami/apps/wordpress1/htdocs/"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>

<Directory "/opt/bitnami/apps/wordpress1/htdocs/">
    Options Indexes MultiViews +FollowSymLinks
    LanguagePriority en
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

<FilesMatch "^\\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>
ErrorLog "logs/error_log"

LogLevel warn
<IfModule log_config_module>

    LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" combined
    LogFormat "%h %l %u %t \\"%r\\" %>s %b" common
    <IfModule logio_module>
      LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" common
</IfModule>
<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/opt/bitnami/apache2/cgi-bin/"
</IfModule>
<Directory "/opt/bitnami/apache2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
DefaultType text/plain
<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>

Include conf/extra/httpd-mpm.conf

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
AddType application/x-httpd-php .php .phtml
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/bitnami/python

ServerSignature Off
ServerTokens Prod

AddType application/x-httpd-php .php
PHPIniDir "/opt/bitnami/php/etc"

Include "/opt/bitnami/apps/phpmyadmin/conf/phpmyadmin.conf"
ExtendedStatus On
<Location /server-status>
  SetHandler server-status
  Order Deny,Allow
  Deny from all
  Allow from localhost
</Location>

Include "/opt/bitnami/apache2/conf/bitnami/httpd.conf"
Include "/opt/bitnami/apps/virtualhost.conf"

Here is my virtual hosts file:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin xx
    DocumentRoot "/opt/bitnami/apps/wordpress1/htdocs"
    ServerName mbird.com
    ServerAlias www.mbird.com
    ErrorLog "logs/wordpress-error_log"
    CustomLog "logs/wordpress-access_log" common
</VirtualHost>
<Directory "/opt/bitnami/apps/wordpress1/htdocs">
 Options Indexes MultiViews +FollowSymLinks
 AllowOverride All
 Order allow,deny
 Allow from all
</Directory>

### WordPress conference.mbird.com configuration ###
<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
 ServerName conference.mbird.com
 ServerAlias www.conference.mbird.com
 ErrorLog "logs/confwordpress-error_log"
 CustomLog "logs/confwordpress-access_log" common
</VirtualHost>
<Directory "/opt/bitnami/apps/wordpress/htdocs">
 Options Indexes MultiViews +FollowSymLinks
 AllowOverride All
 Order allow,deny
 Allow from all
</Directory>
###

© Server Fault or respective owner

Related posts about apache2

Related posts about configuration