Blue Flower

How To Create .htaccess Redirects For Joomla URLs Via cPanel

If you have tried to use the Redirect feature of any hosting control panel like Cpanel, then you have discovered that it does not work with Joomla.  Very frustrating!
With the newer Joomla versions, you have a choice of using your hosting control panel Redirect feature and/or .htaccess file, or the built-in redirect feature of Joomla (click to see other article for other method).

Here is how to get it working without being forced to learn .htaccess commands and formatting.

For this article we will use the following example. We will want http://technotes.whw1.com/categories/14-development/programming redirected to http://technotes.whw1.com/computer-related/development/programming.

Steps

  1. Login to your hosting control panel, like WHW1's cpanel.  This article will be for usage of cpanel and .htaccess with a Joomla installation.

  2. Click on the Redirects icon in the Domains section.



  3. Leave the Type to show as "Permanent (301)", unless you want the redirect to be temporary and plan to change it very soon.  Select your domain, even if you only have one domain, which is common.  Paste or type the portion of the old or unwanted URL (web link/address), and then in the "redirects to" field type the URL you want the visitor to be led to (redirected to).  Click Add button.

    cpanel Redirects. Selection of Permanent.

  4. You should see a response page showing you the redirect that was created.  Click the button of Go Back.



  5. Scroll down and you will see something like this:



  6. Scroll up, and click on the Home icon near the top left (depending on the Style you have chosen).



  7. Open the File Manager



  8. On the question window that pops up, select Web Root or WWW, and check the box for "Show Hidden Files", and click on the Go button.

  9. Scroll down, and push the RIGHT mouse button on .htaccess file name, and select Copy from the menu that shows.



  10. The the copied file a name.  Like below example. Click on Copy Files(s).



  11. Push the RIGHT mouse button on .htaccess file name, and select Code Edit from the menu that shows.



  12. Leave the Character Encoding to be "utf-8", and click on Edit.



  13. The editor will open in a new tab window.  Scroll all the way to the bottom or where ever you see the newly added RewriteCond code that shows your URL label names.  There should be 3 lines added; again most likely at the bottom.  Cut those 3 lines, circled in the example below.



    Here is a copy of the code in text form, in case you want to MODIFY it and use it:

    RewriteCond %{HTTP_HOST} ^technotes\.whw1\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.technotes\.whw1\.com$
    RewriteRule ^categories\/14\-development\/programming$ "http\:\/\/technotes\.whw1\.com\/computer\-related\/development\/programming" [R=301,L]

  14. Scroll back up on the Code Editing window, and change this:

    ## Begin - Custom redirects
    #
    # If you need to redirect some pages, or set a canonical non-www to
    # www redirect (or vice versa), place that code here. Ensure those
    # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
    #
    ## End - Custom redirects

    by pasting into it what you cut earlier, and make it into this (below continues the example of above):

    ## Begin - Custom redirects
    #
    # If you need to redirect some pages, or set a canonical non-www to
    # www redirect (or vice versa), place that code here. Ensure those
    # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
    #
    RewriteCond %{HTTP_HOST} ^technotes\.whw1\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.technotes\.whw1\.com$
    RewriteRule ^categories\/14\-development\/programming$ "http\:\/\/technotes\.whw1\.com\/computer\-related\/development\/programming" [R=301,L]
    #
    ## End - Custom redirects

  15. Save the modified file by clicking on Save Changes button near the top right corner of the open page window.



  16. Now if you go to the old URL on your Internet browser (may require a Refresh/Reload), then it will get redirected to the new URL.  In the above example, going to http://technotes.whw1.com/categories/14-development/programming gets you redirected to http://technotes.whw1.com/computer-related/development/programming.

 

Feel Free To Leave A Good Comment. :)

Look around, and you may find other useful articles.

Leave your comments

Post comment as a guest

0 Character restriction
Your text should be more than 2 characters
Your comments are subjected to administrator's moderation.
  • No comments found