Search

How to Redirect a Page to Another Page or Website Using htaccess

How to Redirect a Page to Another Page or Website Using htaccess

Redirecting a page to another site can be useful for a lot of things including allowing you to display information on different pages or for testing. In this tutorial I'll show you how to redirect a page using the htaccess file.

Many times we want to redirect a page to another page or website. For example, many people like to redirect a Facebook page to their own ‘personal’ page on the social network. I was wondering if there is an easier way to do it? Well guess what – htaccess provides a simple way for you to redirect your domain's home page using just one line of code!

If a page on your website no longer exists and you want to redirect it to a new page or website, you can use the dot htaccess file to redirect visitors.  

Redirect from a page/directory to another domain or the main domain:  

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  


Whenever you open a URL such as example.com/oldpage.html, it will redirect you to example.com/newpage.html 

By following these tips and techniques, you'll be able to effortlessly redirect your website's pages or entire site using htaccess. Whether you're a Linux System Administrator or a Software Engineer, mastering page redirection is a valuable skill that can enhance your overall website management abilities. 

Sys Admin

Sys Admin

I am a Red Hat Certified Engineer (RHCE) and working as an IT Professional since 2012...