Search
-
Recent Posts
Tags
adwords amazon analytics api apple aws blog chrome chromium cloud Design dropbox ec2 email error facebook firefox google google-apps homebrew ipad javascript jQuery linux lion mac microsoft mysql osx os x paypal php plugin quicksilver raspberry pi scam social spam twitter ubuntu unix video windows woo wordpress
Tag Archives: htaccess
Dynamically redirect non-www to www (or vice versa) without hardcoding using .htaccess
After much searching and testing, this is what I’ve up up with: Redirect www to non-www RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] Redirect non-www to www RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://www\.%{HTTP_HOST}/$1 [R=301,L] or RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^(.+)$ [NC] RewriteRule ^(.*)$ http://www\.%1/$1 [R=301,L]