So I've been looking but so far can;t find something that I'm looking for exactly. Looked at this article How can I forward ALL pages to the same exact page on a different domain using .htaccess? but it seems to only redirect my home page.
Currently, I'm using WordPress and I need to be able to forward all pages to a new domain. For example, domain1.com/about-us needs to go to domain2.com/about-us. But I have about 50 pages this needs to work on. I would like to see if there is a 1-5 line code to use for this to work.
Thanks!
Under the Domain category, choose the Redirects menu. You'll see the Create a Redirect section. Here, you'll need to fill in which URL you want to Redirect and where you want it to Redirect To. Make sure your information is correct and choose the right connection protocol – HTTP or HTTPS.
While a 301 redirect indicates that a page has permanently moved to a new location, a 302 redirect means that the move is only temporary. Keep reading to learn more. There are two redirects that can be used to direct site users and search engines to a different URL than they'd originally planned to visit.
A 301 Permanent Redirect permanently redirects one URL to another. You set up a 301 redirect using . htaccess to send visitors to a new URL and tell search engines that a page has moved so that the new page can be properly indexed.
The . Because the WordPress 301 redirect is not always reliable, we recommend issuing the 301 redirect via your . htaccess file. Another benefit is that the . htaccess redirect is slightly faster than redirecting via PHP, because it is loaded even before the rest of the page.
Try putting this (above any wordpress rules) in the htaccess file in domain1.com's document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} domain1.com [NC]
RewriteRule ^(.*)$ http://domain2.com/$1 [L,R=301]
If your 2 domains are one different webservers, or don't share a common document root, you can just use mod_alias, adding this to the htaccess file in domain1.com's document root:
Redirect 301 / http://domain2.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With