Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

www.andrewrockefeller.com <-- Works

andrewrockefeller.com <-- Does not (and I want to redirect it to www.andrewrockefeller.com)

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 *>
  ServerName andrewrockefeller.com
  Redirect 301 / http://www.andrewrockefeller.com/
</VirtualHost>

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]
</IfModule>
# 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

3 Answers 3

up vote 2 down vote accepted

Issue 1: Incorrect DNS

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

dig andrewrockefeller.com 

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

;; QUESTION SECTION:
;andrewrockefeller.com.         IN      A

;; AUTHORITY SECTION:
andrewrockefeller.com.  1739    IN      SOA     dns226.a.register.com. root.register.com. 2013082003 28800 7200 604800 14400

;; Query time: 22 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Oct 31 12:44:47 2013
;; MSG SIZE  rcvd: 98

Appears your domain is registered at Register.com. On their portal, you need to add an A record for

andrewrockefeller.com -> 76.164.206.80

Once you add this A record, your domain.com 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.

Reference: http://wiki.apache.org/httpd/CanonicalHostNames

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 ^/?(.*)         http://example.com/$1 [L,R=301]

This basically says if the domain does not match example.com redirect to example.com. If you want to standardize on www.example.com, 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\.example.com/$1 [L,R=301]
share|improve this answer
    
I have an A record on Register.com, otherwise I don't think the www.andrewrockefeller.com 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 andrewrockefeller.com 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, register.com, 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.

See: http://help.register.com/app/answers/detail/a_id/2882

share|improve this answer
    
My www subdomain works. It's trying to get the www-less address to redirect to www.andrewrockefeller.com 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} != 'www.example.com'">
    Redirect / http://www.example.com/
</If>

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 www.andrewrockefeller.com to redirect on itself in a loop. :| No redirects from andrewrockefeller.com 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.