<IfModule mod_rewrite.c> RewriteEngine On # Force removal of www RewriteCond %{HTTP_HOST} ^www\.(.+)$ RewriteRule ^(.*)$ http://%1/$1 [R=301,L] # (Or force addition of www depending on your cert) RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] # Now Force traffic to use HTTPS RewriteCond %{SERVER_PORT} !443 RewriteRule ^(.*)$ https://securesiteurl.com/$1 [R=301,L] </IfModule>
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Force traffic over HTTPS (See related posts)
Comments on this post
You need to create an account or log in to post comments to this site.
Related Posts
» mod_rewrite rules to serve a... in apache xhtml modrewrite mimetype htaccess
» Block Blacklisted Bandwidth ... in apache htaccess bandwidth hotlinking http_referer mod_rewrite
» Maintenance mode for apache in apache redirect htaccess
» 301 Permanent Redirect rule ... in apache redirect htaccess mod_rewrite
» Protect .svn directories ser... in apache sysadmin svn security subversion htaccess server config cvs protection hidden
» Protect .svn directories usi... in apache sysadmin freebsd svn security subversion htaccess config linux cvs
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails