Redirect sub-domain all post to main domain

I want to redirect all posts that are on subdomain to live domain.

For example, www.blog.mydomain1.com/post-1 to www.mydomain1.com/post-1

Read More

I try this htaccess code , It redirect the main subdomain but it does not redirect the post links

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^blog.mydomain1.com$ [NC]
 RewriteRule ^(.*) http://www.mydomain1.com/$1 [R=301,L]

My Complete HTAccess is

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^blog.(.+)$ [NC]
 RewriteRule ^(.*)$ http://www.%1/$1 [NC,R,L]

# BEGIN MainWP
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/plugins/mainwp-child/(.*)$ /wp-content/plugins/THIS_PLUGIN_DOES_NOT_EXIST [QSA,L]
</IfModule>

# END MainWP

Related posts

1 comment

  1.  RewriteEngine On
     RewriteCond %{HTTP_HOST} ^blog.(.+)$ [NC]
     RewriteRule ^(.*)$ http://www.%1/$1 [NC,R,L]
    

    Clear your browser cache before testing this Redirect.

Comments are closed.