Skip to content

Instantly share code, notes, and snippets.

@elvisciotti
Last active December 11, 2015 10:18
Show Gist options
  • Save elvisciotti/4585785 to your computer and use it in GitHub Desktop.
Save elvisciotti/4585785 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