- Details
- Written by Tech Notes
- Published: 14 April 2014
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
- Login to your hosting control panel, like WHW1's cpanel. This article will be for usage of cpanel and .htaccess with a Joomla installation.
- Click on the Redirects icon in the Domains section.
- 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.
- You should see a response page showing you the redirect that was created. Click the button of Go Back.
- Scroll down and you will see something like this:
- Scroll up, and click on the Home icon near the top left (depending on the Style you have chosen).
- Open the File Manager
- 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.
- Scroll down, and push the RIGHT mouse button on .htaccess file name, and select Copy from the menu that shows.
- The the copied file a name. Like below example. Click on Copy Files(s).
- Push the RIGHT mouse button on .htaccess file name, and select Code Edit from the menu that shows.
- Leave the Character Encoding to be "utf-8", and click on Edit.
- 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]
- 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
- Save the modified file by clicking on Save Changes button near the top right corner of the open page window.
- 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.