I'm trying to do a redirect using .htaccess and am running into a problem I can't identify.
What I want to do: Redirect all pages from my old domain to my new domain. For example: https://www.olddomain.com/fun-blog-post/ would forward to https://www.newdomain.com/blog/fun-blog-post/
My code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com/$1 [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com/$1
RewriteRule (.*)$ https://www.newdomain.com/blog/$1 [L,R=301]
Unexpected Behavior: When I type in olddomain.com, it takes me directly to newdomain.com. However, if I type in olddomain.com/new-blog-post, it doesn't redirect at all. It pulls up a 404 error and just displays olddomain.com/new-blog-post.
I've checked the following two threads already.
.htaccess redirect all pages to new domain
Redirect from old domain to new domain not work
However, I cannot figure this one out. I've tried a few different tweaks, most of which I don't remember, but this seems to be the best solution I can come up with. Can someone please help me see what I am doing wrong?