New to coding, unsure how to deal with conditional redirects

[ad_1]

I am new to coding and I’m trying to set up my htaccess file with conditional redirects. So that if the page it’s redirecting to turns up a 404 error, it will automatically redirect to another page that is up and live

Here’s the code I had generated, but I’m not sure if it’s right. I’m missing or where I could even find the code pre-made?

​

​

RewriteEngine On

RewriteCond %{HTTP\_HOST} \^example.com$

RewriteCond %{REQUEST\_URI} \^/old-url$

RewriteRule \^(.\*)$ \[R=301,L\] [ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer