I know there are lots of stack overflow posts about this. I have this in my /var/www/ directory:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
It should rewrite all http://www.domain.com requests to http://domain.com. I have mod_rewrite enabled, and in /etc/apache2/sites-available/default, I have enabled htaccess:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
All www requests lead to a page not found error. I get a generic verizon search. What the hell am I doing wrong?
EDIT
Here’s the entire file /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
rewrite log file
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850f3b0/initial] (2) init rewrite engine with requested uri /
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850f3b0/initial] (1) pass through /
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850f3b0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/ ->
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850f3b0/initial] (3) [perdir /var/www/] applying pattern '^(.*)$' to uri ''
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850f3b0/initial] (4) [perdir /var/www/] RewriteCond: input='domain.com' pattern='^www\.(.+)$' [NC] => not-matched
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850f3b0/initial] (1) [perdir /var/www/] pass through /var/www/
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8506390/subreq] (2) init rewrite engine with requested uri /index.html
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8506390/subreq] (1) pass through /index.html
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8506390/subreq] (1) [perdir /var/www/] pass through /var/www/index.html
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850d3a8/subreq] (2) init rewrite engine with requested uri /index.cgi
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850d3a8/subreq] (1) pass through /index.cgi
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850d3a8/subreq] (1) [perdir /var/www/] pass through /var/www/index.cgi
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8506390/subreq] (2) init rewrite engine with requested uri /index.pl
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8506390/subreq] (1) pass through /index.pl
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8506390/subreq] (1) [perdir /var/www/] pass through /var/www/index.pl
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850d3a8/subreq] (2) init rewrite engine with requested uri /index.php
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850d3a8/subreq] (1) pass through /index.php
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b850d3a8/subreq] (1) [perdir /var/www/] pass through /var/www/index.php
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (2) init rewrite engine with requested uri /css/style.css
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (1) pass through /css/style.css
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/css/style.css -> css/style.css
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (3) [perdir /var/www/] applying pattern '^(.*)$' to uri 'css/style.css'
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (4) [perdir /var/www/] RewriteCond: input='domain.com' pattern='^www\.(.+)$' [NC] => not-matched
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (1) [perdir /var/www/] pass through /var/www/css/style.css
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8554138/initial] (2) init rewrite engine with requested uri /js/scripts.js
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8554138/initial] (1) pass through /js/scripts.js
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8554138/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/js/scripts.js -> js/scripts.js
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8554138/initial] (3) [perdir /var/www/] applying pattern '^(.*)$' to uri 'js/scripts.js'
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8554138/initial] (4) [perdir /var/www/] RewriteCond: input='domain.com' pattern='^www\.(.+)$' [NC] => not-matched
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8554138/initial] (1) [perdir /var/www/] pass through /var/www/js/scripts.js
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (2) init rewrite engine with requested uri /images/HeaderBkg.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (1) pass through /images/HeaderBkg.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/images/HeaderBkg.gif -> images/HeaderBkg.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (3) [perdir /var/www/] applying pattern '^(.*)$' to uri 'images/HeaderBkg.gif'
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (4) [perdir /var/www/] RewriteCond: input='domain.com' pattern='^www\.(.+)$' [NC] => not-matched
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (1) [perdir /var/www/] pass through /var/www/images/HeaderBkg.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (2) init rewrite engine with requested uri /images/logo.png
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (1) pass through /images/logo.png
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/images/logo.png -> images/logo.png
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (3) [perdir /var/www/] applying pattern '^(.*)$' to uri 'images/logo.png'
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (4) [perdir /var/www/] RewriteCond: input='domain.com' pattern='^www\.(.+)$' [NC] => not-matched
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (1) [perdir /var/www/] pass through /var/www/images/logo.png
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (2) init rewrite engine with requested uri /images/SearchHeadingIco.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (1) pass through /images/SearchHeadingIco.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/images/SearchHeadingIco.gif -> images/SearchHeadingIco.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (3) [perdir /var/www/] applying pattern '^(.*)$' to uri 'images/SearchHeadingIco.gif'
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (4) [perdir /var/www/] RewriteCond: input='domain.com' pattern='^www\.(.+)$' [NC] => not-matched
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85718b0/initial] (1) [perdir /var/www/] pass through /var/www/images/SearchHeadingIco.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b854f600/initial] (2) init rewrite engine with requested uri /images/SearchKeywordBkg.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b854f600/initial] (1) pass through /images/SearchKeywordBkg.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b854f600/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/images/SearchKeywordBkg.gif -> images/SearchKeywordBkg.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b854f600/initial] (3) [perdir /var/www/] applying pattern '^(.*)$' to uri 'images/SearchKeywordBkg.gif'
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b854f600/initial] (4) [perdir /var/www/] RewriteCond: input='domain.com' pattern='^www\.(.+)$' [NC] => not-matched
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b854f600/initial] (1) [perdir /var/www/] pass through /var/www/images/SearchKeywordBkg.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (2) init rewrite engine with requested uri /images/CategoriesHeadingIco.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (1) pass through /images/CategoriesHeadingIco.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/images/CategoriesHeadingIco.gif -> images/CategoriesHeadingIco.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (3) [perdir /var/www/] applying pattern '^(.*)$' to uri 'images/CategoriesHeadingIco.gif'
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (4) [perdir /var/www/] RewriteCond: input='domain.com' pattern='^www\.(.+)$' [NC] => not-matched
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b8504388/initial] (1) [perdir /var/www/] pass through /var/www/images/CategoriesHeadingIco.gif
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85113b8/initial] (2) init rewrite engine with requested uri /images/SRightIco.png
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85113b8/initial] (1) pass through /images/SRightIco.png
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85113b8/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/images/SRightIco.png -> images/SRightIco.png
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85113b8/initial] (3) [perdir /var/www/] applying pattern '^(.*)$' to uri 'images/SRightIco.png'
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85113b8/initial] (4) [perdir /var/www/] RewriteCond: input='domain.com' pattern='^www\.(.+)$' [NC] => not-matched
173.68.188.109 - - [10/Feb/2012:14:58:24 +0000] [domain.com/sid#b8370ad8][rid#b85113b8/initial] (1) [perdir /var/www/] pass through /var/www/images/SRightIco.png
Apache was fine. I had to adjust the cname record for the DNS.
For anyone else having this problem, I changed my CNAME value to domain.com. It was http://www.domain.com. That was cause of my issue.