There's also syntax errors, and the code fails to redirect all non-canonical URL variants due to poor pattern matching/anchoring.
The example htaccess code also comes from very old versions of the file and there are several problems in that code. You should update your htaccess file to use the one from the current version of Joomla. You can get it from the Joomla install file. It's called htaccess.txt there. You should update that file even if you intend to continue using an older version of Joomla.
If you get the newest version of the htaccess file from the latest Joomla installer, it shows exactly where within the htaccess file any redirects should be added.hi i have the same issue but i don't know where i add the code for redirection??
You'll also need this:
Code: Select all
########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
########## End - 301 Redirect