virtualhost rewrite rules; http://domain->http://www.doma
We have 7 domains setup in linode, DNS records all configured the same, with A/AAAA records all pointing to the same linode (same IP). The DNS record is set up for the domain without www. prefix.
The linode is running Ubantu 9.1.
There are virtualhost files for all 7 domains in /apache2/sites-available, and all have been enabled via a2ensite.
Here is a template of the virtualhost file from sites-enabled, where "example" is replaced with the domain name. All sites have the same DocumentRoot (drupal multisite install).
The http://example.com->
ServerAdmin
ServerName example.com
ServerAlias
Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/webroot
AllowOverride None
Order allow,deny
allow from all
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*) http://www.%{HTTP_HOST}:%{SERVER_PORT}/$1 [L,R]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Drupal
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Custom log file locations
LogLevel warn
ErrorLog /var/log/example/error.log
CustomLog /var/log/example/access.log combined
I tried deleting an recreating the DNS record.
I tried adissite disabling the site (it becomes unavailable), then reenabling (aensite) (it becomes available).
Where might I look for clues?
Thanks!
2 Replies
@nacho:
The DNS record is set up for the domain without www. prefix.
Unless this is a typo, a redirect to 'www.example.com ' by the webserver for 'example.com' is not going to work unless you have a resource record (RR) pointing to a destination for www, such as a CNAME, A, or AAAA record.
What happens when you try http:///example.com from a webroswer? This information (domain not found, 404, etc) might help someone clue in on the problem at hand. Actually providing the domain(s) would allow someone to maybe diagnosing the problem, without requiring feedback from you.
My suggestions: 1) Rule out DNS: verify DNS records exist and are correct, 2) Verify the rewrite configuration is correct (not my area of expertise), 3) check your web server logs as to what is happening to the requests.
I suspect if it's a web server configuration problem, it's most likely a typo. Try copying the configuration from one of the working domains, then paste it modifying it for the not working domain.
–
Travis
127.0.0.1 localhost
173.255.192.16 example.com example
This, it think, was allowing the domain to be resolved without reference to the vhost configuration.