Skip to content

Instantly share code, notes, and snippets.

@ChriRas
Created November 17, 2014 10:46
Show Gist options
  • Save ChriRas/903d64450e99e6649d13 to your computer and use it in GitHub Desktop.
Save ChriRas/903d64450e99e6649d13 to your computer and use it in GitHub Desktop.
Apache htaccess/virtualhost rule to redirect 301 non-www version to www-version (to avoid duplicate URLs on search engines) e.g. example.org/one/two -> www.example.org/one/two
# .htaccess or Apache vhost
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment