Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently trying to set up my personal webpage.

I am using a VPS and have manually installed Wordpress, and everything seems to work... except if I go to the non-www version of my website, it comes up with a page not found. <-- Works <-- Does not (and I want to redirect it to

I have tried adding RewriteEngine functionality to my .htaccess, and that isn't working.

I have also tried adding the 'most-voted' method of adding to my default file (which apache2.conf pulls from:

<VirtualHost *>
  Redirect 301 /

Seeing how many people are able to get the above working, is there something else I may be missing to allow that to function?

Thank you for your time!

EDIT: My .htaccess file is as follows:

# 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]
# END WordPress

The #Wordpress section was autocreated when I changed the settings from ?p=1 (ugly links) to prettylinks. Any proposed solutions I've found on here I've tried out and restarted apache2, and it hasn't worked.

share|improve this question

closed as off-topic by TheCleaner, Ward, cole, squillman, kce Nov 1 '13 at 18:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is a site dedicated to professionals; novice questions are off-topic. Please see the Help Center for more information on topicality. The best advice we can give you is to hire a professional to help you out." – Ward, cole, squillman
If this question can be reworded to fit the rules in the help center, please edit the question.

Hey, I apologize if this is seen as a 'novice question', but there are many other questions (just look to your sidebar) that are nearly identical - it just happens that my main issue was something that I overlooked. The answers below all include redirects which are both needed and useful. I had visited all of these questions and tried their solutions which had led me to creating my own question, because logic follows that maybe I had run into an issue that hadn't been seen thus far. – Andrew Nov 2 '13 at 14:55
up vote 2 down vote accepted

Issue 1: Incorrect DNS

You do not have an A or CNAME record for As a result, the browser cannot translate your domain name into an IP address.


; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.2 <<>>
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31887
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;         IN      A

;; AUTHORITY SECTION:  1739    IN      SOA 2013082003 28800 7200 604800 14400

;; Query time: 22 msec
;; WHEN: Thu Oct 31 12:44:47 2013
;; MSG SIZE  rcvd: 98

Appears your domain is registered at On their portal, you need to add an A record for ->

Once you add this A record, your version should resolve.

Issue 2: Canonical Domain Name

I think Wordpress will redirect domains correctly but to assure this, you are better off forcing anything that does not match what you want to be what you want.


I prefer using mod_rewrite and this method:

# And for a site running on port 80
RewriteCond %{HTTP_HOST}   !^example\.com [NC]
RewriteCond %{HTTP_HOST}   !=""
RewriteRule ^/?(.*)$1 [L,R=301]

This basically says if the domain does not match redirect to If you want to standardize on, you would modify this accordingly:

# And for a site running on port 80
RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !=""
RewriteRule ^/?(.*)         http://www\$1 [L,R=301]
share|improve this answer
I have an A record on, otherwise I don't think the address would resolve - which wasn't my issue. I have tried adding mod_rewrite to my .htaccess but nothing so far has worked. Could there be another issue that I may be overlooking? – Andrew Oct 31 '13 at 20:13
i believe he's saying that you need to add an arecord or cname for the domain itself... if you ping you'll get a host unknown from outside... thats why all the rewriting is failing. – art3mis Nov 1 '13 at 13:39
Whoa... this was actually my issue. BIG thank you to both of you! I needed to add the naked domain (@). I must have tried adding it to CNAME first which threw an error so in my limited knowledge I gave up on adding it to A as well. – Andrew Nov 1 '13 at 15:32

Your answer lies in DNS. Your domain name registrar,, should provide an option to manage your DNS entries. In that section of your control panel there will likely be an option to include a www. subdomain.

If there isn't you can possibly create it on your own by adding it as a subdomain that points to the root folder of your hosting.


share|improve this answer
My www subdomain works. It's trying to get the www-less address to redirect to that is my issue. – Andrew Oct 31 '13 at 20:17
My apologies. My reading comprehension needs more exercise. :) – Kemo Sabe Oct 31 '13 at 20:55
<If "%{HTTP_HOST} != ''">
    Redirect /

As explained here under Canonical Hostnames Apache Docs Remapping/Rewriting

share|improve this answer
This didn't work. I'm not sure if maybe permissions are wrong somewhere, or what, but the best I've been able to do is to get to redirect on itself in a loop. :| No redirects from seem to be working. – Andrew Nov 1 '13 at 0:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.