Rewriterule vs simple redirect

Discuss Search Engine Optimization in relation to Joomla! 2.5. This forum will also have discussions on SEF/SEO Joomla! 2.5 extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
jimreynolds
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Sat Dec 04, 2010 1:36 am
Location: Boston MA USA
Contact:

Rewriterule vs simple redirect

Post by jimreynolds » Thu Jul 07, 2011 9:19 am

For seo purposes, I changed the urls for several interior pages in my site and now I need inbound links to resolve to the new urls. I have accomplished this in the .htaccess file as follows:

Redirect /old-directory http://www.mysite.com/new-directory

My question/concern is whether this is seen as 'permanent' the way the Rewriterule is. For example, I redirect http://mysite.com to http://www.mysite.com as follows:

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

The question is whether, by choosing the simpler method for the interior pages, I am sacrificing any seo effect. If so then I can easily make the change using the Rewriterule.

User avatar
kenmcd
Joomla! Champion
Joomla! Champion
Posts: 5672
Joined: Thu Aug 18, 2005 2:09 am
Location: California
Contact:

Re: Rewriterule vs simple redirect

Post by kenmcd » Mon Jul 11, 2011 7:29 am

.
Redirect by default returns a 302 status (temporary redirect).

So change this:
Redirect /old-directory http://www.mysite.com/new-directory

To:
Redirect permanent /old-directory http://www.mysite.com/new-directory
or
Redirect 301 /old-directory http://www.mysite.com/new-directory
or
RedirectPermanent /old-directory http://www.mysite.com/new-directory

.
██ LibreTraining

jimreynolds
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Sat Dec 04, 2010 1:36 am
Location: Boston MA USA
Contact:

Re: Rewriterule vs simple redirect

Post by jimreynolds » Mon Jul 11, 2011 3:57 pm

Worked perfectly - thx!

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: Rewriterule vs simple redirect

Post by g1smd » Tue Jul 12, 2011 8:48 am

If you use RewriteRule for any of your rules, you must use it for ALL of your rules.

RewriteRule is parsed by mod_rewrite. Redirect is parsed by mod_alias.

The .htaccess file is parsed in "per module" order.

The problem is that if your server runs mod_rewrite before it runs mod_alias your internal rewritten paths will be exposed as new URLs.

Instead of

Redirect 301 /oldfolder http://www.example.com/newfolder

use

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


Make sure that external redirects are listed before internal rewrites.

Make sure the non-www to www external redirect is the last redirect before the internal rewrites.

The htaccess.txt file that comes with the latest version of Joomla shows exactly where in the file external redirects should be placed.
Online since 1995.

jimreynolds
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Sat Dec 04, 2010 1:36 am
Location: Boston MA USA
Contact:

Re: Rewriterule vs simple redirect

Post by jimreynolds » Tue Jul 12, 2011 9:30 am

OK thank you. I remember seeing the reference to the external redirects in the .htaccess file.


Locked

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 2.5”