free hit counter

There's a couple ways to do redirects in Joomla.

You could either use the redirect extension or redirect using your .htaccess file.

There are three types of redirects that are most commonly used:

  • 301 "moved permanently"
  • 302 "Moved Temporarily"
  • Meta Refresh

A redirect is simply a way to send users and the search engines to a different URL than the one they originally were trying to access. 

For example, lets say you were trying to go to domain.com/page-1, but I'd moved it on the site. I could use a redirect to automatically take you from domain.com/page-1 to the correct page, domain.com/page-2.

301 Moved Permanently Redirect

When it comes to Search Engine Optimization, a 301 redirect is preferrable. It passes between 90-99% of the "link juice" to the new page. 

302 Moved Temporarily Redirect

The 302 redirect does not pass any link juice to the new page whatsoever. You'd really want to only use a 302 redirect for very short term moves, such as maintenance or to promote a "happy hour" sale.

Meta Refresh

While both the above methods are server level redirects, the meta refresh is a page level redirect. It's generally slower and not recommended to use for SEO. You'll see meta refreshes most of the time with pages that alert you with "If you are not redirected in XX seconds, click here".

Which Redirect Method To Use?

Generally speaking, the 301 redirect method is the best way of moving users and search engines to the correct page. Not only does it alert the search engine that the page has moved, but also tells it that the new page is permanent and authoritative. This means that the search engines will give up to 99% of the link juice and search engine rank to the new page.

Keep in mind that when you do use a 301 redirect, it will take the search engines some tiime to see the 301, recognize it's existance and give the new page all the weight, rankings and trust that the old page had. You can speed up the process to some extent by using the Google Webmaster Tools "Fetch as Google" tool to indicate that you would like Google to recrawl the URL.

Apache 301 Redirects

If your site uses apache or apache2, then you need to have the mod_rewrite apache module installed and turned on. Your Joomla! .htaccess file has the line

RewriteEngine On

already included. Alternately, if you have have root-level access to your server or webhosting, you can edit the apache config file to turn rewrites on universally.

Two Ways To Do 301 Redirects via .htaccess

There are two ways to do redirects using your .htaccess file.

Redirect an individual page

You would use this if there's only a few pages that need to be redirected, or when regular expressions just cannot be used.

Redirect 301 /category/page http://domain/newcategory/new-page

Regular Expression Redirects

When there is a constant in the URL that needs to be changed (for example: moving all the /blog/ pages to /page/), you can do a regular expression redirect. The following are characters and operators used gor regex redirects.

  • . Period–matches anything
  • * Asterisk–matches zero or more of the preceding characters
  • + Plus sign–matches one or more of the preceding character
  • ( ) Parenthesis–enclosing a value in parenthesis will store what was matched in a variable to be used later; this is also referred to as a back-reference
  • (value1|value2)–enclosing two or more values in parenthesis and separating them with a pipe character is the equivalent of saying: “matching value1 OR value2”

So, for redirecting all /blog/ URLS to /page/, you would use this:

RewriteRule ^blog/(.*) http://www.example.com/page/$1 [R=301,L] 

Redirect non-www to WWW and vise-versa

You can also use your .htaccess to force either WWW or non-www URLs. In order to do this, you'd include this directive in the .htaccess file

To Force the www site:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

Forceing the non-www site:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

 


About Joomla Resources

JoomlaResources.com is an unofficial blog for Joomla! news, extensions, templates and other useful information. We are in no way affiliated with or endorsed by Open Source Matters or the Joomla! Project. The official resources page is located at resources.joomla.org

powered by Joomla

Web Hosting