How to set up domain 301 from a.com/pagecontent.html to b.com/pagecontent.html? I think when i set up domain 301 it will work for all pages, but no. Type a.com it will redirect to b.com, but no reaction for a.com/pagecontent.html.
Need some help!!!
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
The solution is to use variables. Each wildcard corresponds to a variable when can be referenced in the forwarding address. The variables are represented by a $ followed by a number. To refer to the first wildcard you'd use $1, to refer to the second wildcard you'd use $2, and so on.
To fix the forwarding from the root to www in the above example, you could use the same pattern:
example.com/*
You'd then set up the following URL for traffic to forward to:
http://www.example.com/$1
In this case, if someone went to:
example.com/some-particular-page.html
They'd be redirected to:
http://www.example.com/some-particular-page.html
Thank you, I will try out.Add to .htaccess on the old site:
Code:RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC] RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
Replace "olddomain" and "newdomain" as appropriate.
If you aren't comfortable, familiar with or able to edit .htaccess then use https://support.cloudflare.com/hc/en-us/articles/200172286-Configuring-URL-forwarding-or-redirects-with-Cloudflare-Page-Rules