{"id":107,"date":"2012-07-16T11:42:25","date_gmt":"2012-07-16T11:42:25","guid":{"rendered":"http:\/\/vickistan.com\/?p=107"},"modified":"2014-01-20T22:00:50","modified_gmt":"2014-01-20T22:00:50","slug":"redirect-https-traffic-to-http-in-htaccess","status":"publish","type":"post","link":"https:\/\/vickistan.com\/?p=107","title":{"rendered":"Common rewrite rules"},"content":{"rendered":"<p>The easiest way to redirect one site to another is by adding the following to the Virtualhost:<\/p>\n<p>Redirect 301 \/ http:\/\/newsite.com\/<\/p>\n<p>Note: When AllowOverride is set to allow the use of .htaccess files, Apache will look in every directory for .htaccess files. Permitting .htaccess files causes a performance hit, whether or not you actually even use them! The .htaccess file is loaded every time a document is requested.<\/p>\n<p><code><strong>Redirect <\/strong><strong>https traffic to http<\/strong><\/code><\/p>\n<p>By redirecting everything that comes in on port 443:<\/p>\n<p><code>RewriteEngine On<br \/>\nRewriteCond %{SERVER_PORT} ^443$<br \/>\nRewriteCond %{HTTP_HOST} ^(www.)mydomain\\.com$ [NC,OR]<br \/>\nRewriteRule ^\/(.*)http:\/\/www\\.mydomain\\.com\/$1 [R,L]<\/code><\/p>\n<p>or by checking the x-forwarded-proto header:<\/p>\n<p>RewriteCond %{HTTP:X-Forwarded-Proto} !https<br \/>\nRewriteRule ^(.*)$ https:\/\/www.domain.com$1 [R=301,L]<\/p>\n<p><strong>Redirect <\/strong><strong>http traffic to https<\/strong><\/p>\n<p>RewriteEngine On<br \/>\nRewriteCond %{HTTPS} !on<br \/>\nRewriteRule (.*) https:\/\/%{HTTP_HOST}%{REQUEST_URI}<\/p>\n<p><strong>Redirect non-www to www:<\/strong><br \/>\n(If you see an Internal Server error, check the logs for APC errors)<\/p>\n<p>RewriteEngine On<br \/>\nRewriteBase \/<br \/>\nRewriteCond %{HTTP_HOST} ^yourdomain.com [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/www.yourdomain.com\/$1 [L,R=301]<\/p>\n<p>or<\/p>\n<p>RewriteEngine On<br \/>\nRewriteCond %{HTTP_HOST} !^www\\.<br \/>\nRewriteRule ^(.*)$ http:\/\/www.%{HTTP_HOST}\/$1 [R=301,L]<\/p>\n<p><strong>Redirect www to non-www:<\/strong><\/p>\n<p>RewriteEngine On<br \/>\nRewriteBase \/<br \/>\nRewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/yourdomain.com\/$1 [L,R=301]<\/p>\n<p><strong>Redirect to maintenance page that displays image .jpg<\/strong><\/p>\n<p>Options +FollowSymlinks<br \/>\nRewriteEngine on<br \/>\nRewriteCond %{REQUEST_URI} !\/maintenance.html$<br \/>\nRewriteCond %{REQUEST_URI} !\/image.jpg$<br \/>\nRewriteRule $ \/maintenance.html [R=302,L]<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Redirect for purpose of changing displayed URL<\/strong><br \/>\nRewriteCond %{SERVER_NAME}\u00a0 ^fubar.com$<br \/>\nRewriteRule ^\/$ http:\/\/fubar.net [L]<\/p>\n<p>#To make all letters in the url lowercase<br \/>\nRewriteEngine on<br \/>\nRewriteBase \/<br \/>\nRewriteMap insensitive tolower:<br \/>\nRewriteRule ^[\\\/]*(.*)$ \/${insensitive:$1} [R,L]<\/p>\n<p>&nbsp;<\/p>\n<p>#For phpMyAdmin<br \/>\nRewriteCond %{HTTPS} off$<br \/>\nRewriteRule ^\/phpmyadmin https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]$<\/p>\n<p>RedirectMatch 301 ^(\/phpmyadmin[^\/]*\/.*)$ https:\/\/hostname$1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The easiest way to redirect one site to another is by adding the following to the Virtualhost: Redirect 301 \/ http:\/\/newsite.com\/ Note: When AllowOverride is set to allow the use of .htaccess files, Apache will look in every directory for &hellip; <a href=\"https:\/\/vickistan.com\/?p=107\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=107"}],"version-history":[{"count":26,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":590,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/107\/revisions\/590"}],"wp:attachment":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}