If a page on your website no longer exists and you want to redirect visitors to a new page or website, you can use the .htaccess file to set up a permanent redirect. This helps maintain your SEO and provides a better user experience.
Redirect from a specific page to a domain:
RewriteEngine on
Redirect 301 /mypage.html http://example.com
Redirect from one page to another page:
# Redirect from a page/directory to another page
Redirect 301 /oldpage.html /newpage.html
When you visit a URL such as example.com/oldpage.html, it will automatically redirect you to example.com/newpage.html.
You can repeat these steps for any additional URLs you’d like to shorten or redirect by adding more Redirect 301 rules in your .htaccess file using the following format:
RewriteEngine on
Redirect 301 /your-short-url.html http://yourdomain.com/your-long-path.html