How to Create Redirections with .htaccess

htaccess redirections

.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.

Author

  • Valentin Garcia

    Valentin discovered Joomla in 2010, and since then he has considered it as the best CMS. Valentin has been coding extensions and templates for Joomla for many years and truly enjoys helping people build their own websites with Open Source tools. He lives in San Julián, Jalisco, México.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x