Skip to content

Instantly share code, notes, and snippets.

@pavelbinar
Created February 24, 2014 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavelbinar/9190394 to your computer and use it in GitHub Desktop.
Save pavelbinar/9190394 to your computer and use it in GitHub Desktop.
htaccess redirect non-www to www
# Enable mod rewrite and restart server
a2enmod rewrite
service apache2 restart
# Edit .htaccess file in domain root directory
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment