How to Create Redirections with .htaccess
.htaccess provides an easy way to replace old or broken links with a new url.
In this tutorial we will show you how this process works for Joomla, WordPress and Drupal.
Create a redirection
Open your .htaccess file with a code editor or through cPanel.
Define the old and new urls separated by an empty space after “Redirect 301”.
See the example below:
Redirect 301 /old-url /new-url
Test the redirection
In your browser, go to yoursite.com/old-url. It should automatically point to yoursite.com/new-url which would mean the update is working.
Redirect to a different domain
You can redirect a url to a different domain by including it in the syntax. This is very useful when you change the domain name and want your users to reach the new website when they try to visit the old one.
Redirect 301 /some-url http://www.anothersite.com/some-url
To test the update, go to yoursite.com/some-url. It should automatically point to anothersite.com/some-url.