How to 301 redirect all pages from one domain to one page in another domain

I am trying to do 301 redirects in an htacess file. I want to point all pages in one domain to one page in another domain, and I don't want to manually redirect all individual pages.

Ex: www.olddomain.com/1.html and www.olddomain.com/2.html should be listed at www.newdomain.com.

Hope someone can help me.

0
source share
2 answers
RewriteCond %{HTTP_HOST} .*olddomain\.com$ RewriteRule ^ http://www.newdomain.com/one-single-page.html [L,R=301] 
+1
source

I had the same problem, but it works fine for me to accomplish what you want, I actually need to contrast, for each page from the old domain, to redirect to the new domain, but keep the internal structure so bad that I think!

 redirectMatch 301 ^/ http://www.newdomain.com 
0
source

Source: https://habr.com/ru/post/1445100/


All Articles