i have two websites,
both websites contains few pages, and wordpress blog, please following structure
www.firstwebsite.com
-Root
-index.html
-about.html
-Blog
-blog page1
-blog page2
www.secondwebsite.com
-Root
-index.html
-about.html
-Blog
-blog page1
-blog page2
now, I want to redirect all the blog pages (i.e. pages under blog folder) of http://www.firstwebsite.com to the http://www.secondwebsite.com/blog, using htaccess 301 redirect.
I know i can redirect like
Redirect 301 /a.html www.secondwebsite.com/blog
Redirect 302 /b.html www.secondwebsite.com/blog
but if there any simple way, so i can redirect all pages by writing just line in .htaccess file, as destination for all the pages is same
Use a
RewriteRulefor thisRewriteCondis a conditional match on the request’s hostname. So above, we’re only applying the rewrite to requests matchingwww.firstwebsite.com. The[NC]on the end makes it a case-insensitive match.The
RewriteRuleuses the expressionBlog/(.*)to match all requests to the Blog directory, capturing everything after/in a match group. The request is then rewritten intowww.secondwebsite.com/Blogusing the match from the request(.*)as$1, so the whole request comes out identically inwww.secondwebsite.com.