Domain forwarding question

I’m changing a company name and need to switch from to All of the URLs on domain1 have a corresponding URL on domain2. Both domains are on cPanel hosting.

I want to forward all URLs to the equivalent URL. For example should forward to Parameters in the URL (ie ?var=xxx&var2=yyy) should also forward.

I do not want to forward other subdomains. The MX records for email are handled by a different server and should not forward. It may be worth noting that the .htaccess file is used to force www (ie forwards to and that DNS management is handled through the Cloudflare CDN service.

What would be the best way to set-up the forwarding? I’d prefer to eventually close the domain1 cPanel account, but I also do not mind keeping it since it costs me nothing to do so.


Use the 3rd one down

// 1:1 redirect - all old domain files will be redirected to new domain file locations
RewriteRule .*$1 [R=301,L]

Thanks for the link. Unfortunately they made a mistake and repeated the solution for the first condition, which is “redirect all files from old domain to root of new domain”.

I did more searching and came up with this excellent solution. It has both a www and non-www example. Since the new site also redirects non-www to www, I was able to use the www version of the code on the old site.

It’s not repeated look closer

Don’t forget parentheses.

RewriteRule SIZE=4[/SIZE]$1 [R=301,L]

Apache has a Redirect directive for exactly this kind of situation.

[FONT=Courier New]# htaccess on
Redirect permanent /[/FONT]

I actually had the parentathese in there originally and was told by someone I believed (don’t remember) that they were not nessesarry if I was only doing yada yada

In the first two examples on your site, the parentheses are indeed not necessary, because you’re not using any captured value in the replacement. But in your third example, the replacement uses $1, which will be blank unless you use parentheses to capture the path.

Ahh ok. Only the third? Not the 4th?

The fourth is a redirect, not a rewrite rule. It doesn’t even take regular expressions.

Lol sorry I should of looked first I guess before asking.