Apache's mod_rewrite or Digital Ocean's DNS Records?

  • Posted May 17, 2013

I was trying to figure out how to redirect a website such that will lead to instead of giving me a 404 error when I saw this Apache guide:

I am wondering will this be better than using the DNS records in Digital Ocean’s GUI, considering that the DNS records are still not working despite setting them up last night (They should have propagated by now…)



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Ah I see; I thought having only one of them works :X

Make sure you point the IP of the server to your dns records. <br> <br>@ A <br>www CNAME @ <br> <br>or <br>www A <br> <br>Add the following to your .htaccess. <br> <br># From www to non-www <br><IfModule mod_rewrite.c> <br>RewriteEngine On <br>RewriteBase / <br>RewriteCond %{HTTP_HOST} ^$ [NC] <br>RewriteRule ^(.)$$1 [R=301,L] <br></IfModule> <br> <br>From non-www to www <br># Force www in HTTP <br>RewriteEngine On <br># line below is optional <br># RewriteCond %{REQUEST_URI} !^/(blog| <br>RewriteCond %{HTTP_HOST} ^ <br># RewriteCond %{SERVER_PORT} 80 <br>RewriteRule ^(.)$$1 [R=301,L]

You have to have DNS records for your subdomains to resolve to your droplet. You should also configure apache properly to redirect from non-www to www (or from www to non-www).