{"id":445,"date":"2009-12-27T08:33:14","date_gmt":"2009-12-27T12:33:14","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=445"},"modified":"2013-03-20T08:42:25","modified_gmt":"2013-03-20T12:42:25","slug":"how-to-redirect-a-website-using-htaccess","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/how-to-redirect-a-website-using-htaccess","title":{"rendered":"How to redirect a website using .htaccess?"},"content":{"rendered":"<blockquote><p><span style=\"color: #0000ff;\"><strong>How to redirect a website using .htaccess?<\/strong><\/span><\/p><\/blockquote>\n<p>Redirect website http:\/\/mydomain.com to http:\/\/www.mynewdomain.com<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>RewriteEngine on<br \/>\nRewriteCond %{HTTP_HOST} ^mydomain\\.com$<br \/>\nRewriteRule ^(.*)$ http:\/\/www.mynewdomain.com [R=301,L]<\/strong><\/span><\/p><\/blockquote>\n<p>Redirect website mydomain.com with and without www requests to http:\/\/www.mynewdomain.com<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>RewriteEngine on<br \/>\nRewriteCond %{HTTP_HOST} ^www\\.mydomain\\.com$ [OR]<br \/>\nRewriteCond %{HTTP_HOST} ^mydomain\\.com$<br \/>\nRewriteRule ^(.*)$ http:\/\/www.mynewdomain.com [R=301,L]<\/strong><\/span><\/p><\/blockquote>\n<p>Redirect requests from http:\/\/mydomain.com to http:\/\/mydomain.com\/subdirectory i.e. redirecting requests from main domain to a sub-directory.<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>RewriteEngine on<br \/>\nRewriteCond %{HTTP_HOST} ^www\\.mydomain\\.com$ [OR]<br \/>\nRewriteCond %{HTTP_HOST} ^mydomain\\.com$<br \/>\nRewriteRule ^(.*)$ http:\/\/www.mydomain.com\/subdirectory\/ [R=301,L]<\/strong><\/span><\/p><\/blockquote>\n<p>Redirect all http (80) requests of a domain to https (443) i.e. redirecting requests from non-secure port to a secure port.<\/p>\n<blockquote><p><span style=\"color: #0000ff;\"><strong>RewriteEngine On<br \/>\nRewriteCond %{SERVER_PORT}\u00a0\u00a0\u00a0\u00a0\u00a0 !443<br \/>\nRewriteRule ^(.*)$ https:\/\/mydomain.com\/$1 [R,L]<\/strong><\/span><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>How to redirect a website using .htaccess?<br \/>\nRedirect website http:\/\/mydomain.com to http:\/\/www.mynewdomain.com<br \/>\nRewriteEngine on<br \/>\nRewriteCond %{HTTP_HOST} ^mydomain\\.com$<br \/>\nRewriteRule ^(.*)$ http:\/\/www.mynewdomain.com [R=301,L]<br \/>\nRedirect website mydomain.com with and without www requests to http:\/\/www.mynewdomain.com<br \/>\nRewriteEngine on<br \/>\nRewriteCond %{HTTP_HOST} ^www\\.mydomain\\.com$ [OR]<br \/>\nRewriteCond %{HTTP_HOST} ^mydomain\\.com$<br \/>\nRewriteRule ^(.*)$ http:\/\/www.mynewdomain.com [R=301,L]<br \/>\nRedirect requests from http:\/\/mydomain.com to http:\/\/mydomain.com\/subdirectory i.e. redirecting requests from main domain to a sub-directory.<br \/>\nRewriteEngine on<br \/>\nRewriteCond %{HTTP_HOST} ^www\\.mydomain\\.com$ [OR]<br \/>\nRewriteCond %{HTTP_HOST} ^mydomain\\.com$<br \/>\nRewriteRule ^(.*)$ http:\/\/www.mydomain.com\/subdirectory\/ [R=301,L]<br \/>\nRedirect all http (80) requests of a domain to https (443) i.e. redirecting requests from non-secure port to a secure port.<br \/>\nRewriteEngine On<br \/>\nRewriteCond %{SERVER_PORT}\u00a0\u00a0\u00a0\u00a0\u00a0 !443<br \/>\nRewriteRule ^(.*)$ https:\/\/mydomain.com\/$1 [R,L]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[623,619,622,620,621],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/445"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":6,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"predecessor-version":[{"id":2195,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions\/2195"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}