Skip to content

Instantly share code, notes, and snippets.

@masiorama
Created January 8, 2013 08:48
Show Gist options
  • Save masiorama/4482268 to your computer and use it in GitHub Desktop.
Save masiorama/4482268 to your computer and use it in GitHub Desktop.
Apache: skel virtual host global rewrite www to non-www
<Directory /var/www/vhosts/@domain_name@/httpdocs>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</Directory>
#/var/www/vhosts/.skel/0/conf/vhost.conf
#/var/www/vhosts/.skel/0/conf/vhost_ssl.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment