{"id":41,"date":"2013-08-18T12:06:46","date_gmt":"2013-08-18T12:06:46","guid":{"rendered":"http:\/\/xavia360.org\/blog\/?p=41"},"modified":"2013-08-18T12:06:46","modified_gmt":"2013-08-18T12:06:46","slug":"wordpress-htaccess-redirection","status":"publish","type":"post","link":"http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/","title":{"rendered":"WordPress .htaccess redirection"},"content":{"rendered":"<p>Few days before I was stuck in issue of .htaccess redirection with wordpress. I found solution after many hours efforts and want to post it to others that if any other get stuck in such condition then may be he will found me post and also I get another encounter then this post will help me and save time. If you have one hosting and many domains \u00a0in one hosting and u want that all links redirect to one domain then what to do. We can do it from .htaccess so we have to write it in such a way that the request from every domain get redirected to the main domain and requests from main domain works normally. See the .htaccess below which can do this job.<\/p>\n<p>&nbsp;<\/p>\n<pre>\r\nRewriteOptions inherit\r\n\r\n# BEGIN WordPress\r\n&lt;IfModule mod_rewrite.c&gt;\r\nRewriteEngine On\r\nRewriteBase \/\r\nRewriteRule ^index\\.php$ - [L]\r\n\r\n# New code to redirect from domainone.net to maindomain.com\r\n# Permanent redirect for caching purposes, also include the query string\r\nRewriteCond %{HTTP_HOST} ^domainone\\.net\r\nRewriteRule (.*) http:\/\/maindomain.com\/$1 [R=permanent,QSA,L]\r\n\r\n# New code to redirect from www.domainone.net to www.maindomain.com\r\nRewriteCond %{HTTP_HOST} ^www\\.domainone\\.net\r\nRewriteRule (.*) http:\/\/www.maindomain.com\/$1 [R=permanent,QSA,L]\r\n\r\n# New code to redirect from domainone.com to maindomain.com\r\n# Permanent redirect for caching purposes, also include the query string\r\nRewriteCond %{HTTP_HOST} ^domainone\\.com\r\nRewriteRule (.*) http:\/\/maindomain.com\/$1 [R=permanent,QSA,L]\r\n\r\n# New code to redirect from www.domainone.com to www.maindomain.com\r\nRewriteCond %{HTTP_HOST} ^www\\.domainone\\.com\r\nRewriteRule (.*) http:\/\/www.maindomain.com\/$1 [R=permanent,QSA,L]\r\n\r\n# New code to redirect from domainone.pk to maindomain.com\r\n# Permanent redirect for caching purposes, also include the query string\r\nRewriteCond %{HTTP_HOST} ^domainone\\.pk\r\nRewriteRule (.*) http:\/\/maindomain.com\/$1 [R=permanent,QSA,L]\r\n\r\n# New code to redirect from www.domainone.pk to www.maindomain.com\r\nRewriteCond %{HTTP_HOST} ^www\\.domainone\\.pk\r\nRewriteRule (.*) http:\/\/www.maindomain.com\/$1 [R=permanent,QSA,L]\r\n\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteRule . \/index.php [L]\r\n&lt;\/IfModule&gt;\r\n\r\n# END WordPress\r\n\r\n<\/pre>\n<p><span class='st_facebook_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='facebook'><\/span><span class='st_twitter_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='twitter'><\/span><span class='st_linkedin_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='linkedin'><\/span><span class='st_email_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='email'><\/span><span class='st_sharethis_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='sharethis'><\/span><span class='st_fblike_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='fblike'><\/span><span class='st_plusone_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='plusone'><\/span><span class='st_pinterest_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='pinterest'><\/span><\/p>","protected":false},"excerpt":{"rendered":"<p>Few days before I was stuck in issue of .htaccess redirection with wordpress. I found solution after many hours efforts and want to post it [&hellip;]<\/p>\n<p><span class='st_facebook_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='facebook'><\/span><span class='st_twitter_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='twitter'><\/span><span class='st_linkedin_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='linkedin'><\/span><span class='st_email_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='email'><\/span><span class='st_sharethis_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='sharethis'><\/span><span class='st_fblike_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='fblike'><\/span><span class='st_plusone_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='plusone'><\/span><span class='st_pinterest_vcount' st_title='WordPress .htaccess redirection' st_url='http:\/\/xavia360.org\/blog\/wordpress-htaccess-redirection\/' displayText='pinterest'><\/span><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/posts\/41"}],"collection":[{"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":1,"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":42,"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/posts\/41\/revisions\/42"}],"wp:attachment":[{"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xavia360.org\/blog\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}