Configuring htaccess for joomla 3 (redirect loop problem)

AddDefaultCharset utf-8
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
RewriteRule ^index\.php$ http://website.com/ [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /home\ HTTP/ 
RewriteRule ^index\.php$ http://website.com/ [R=301,L]

I have problems with htaccess file. All pages work well - no redirect loop. I have problems with page website.com/articles (redirect loop) but page website.com/articles/videoblog works well. What do i need to fix - so there will be no redirect loop? Can you tell me what do i need to fix? P.S. I want to make website seo friendly - so you see i try to remove / at the end of the link, no .php webpages and no www redirect

c77,

Aw, I’ve got to parse your .htaccess (is this all you have?) one line at a time to give you comments.

AddDefaultCharset utf-8
# okay
Options +FollowSymLinks
# should already be in the httpd.conf, i.e., not needed
RewriteEngine On
# good - except that, technically, the value is "on" (without the quotes) but On works, too
RewriteBase /
# If you're in the DocumentRoot, you don't need this
# moreover, it changes directories on you without notice so I don't use this at all (a personal problem)
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# good - remove www'd domain name although I prefer
# RewriteRule .?$ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]]
# any host? Argh! You don't use that generated variable so lose the first condition
# why the NoCase flag to match / - NoCase should 'never' be used against a {REQUEST_URI}
# besides you don't need the second condition either as the (/) (generate a variable to match the /? ARGH!
# don't overlook the typo with the double ]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
RewriteRule ^index\.php$ http://website.com/ [R=301,L]
# {THE_REQUEST} is a nasty variable but you just don't need anything before the escaped space
# and no need for anything after the last escaped space (too bad we can't use ^ and $)
# but, again, you don't need the condition because RewriteCond %{IS_SUBREQ} false
# does the same job with ^index\.php$ as the RewriteRule's regex
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /home\ HTTP/ 
RewriteRule ^index\.php$ http://website.com/ [R=301,L]
# ditto

I hope that helped.

You’ve actually done a really good job but a review of my mod_rewrite tutorial might help sharpen the edges a bit: http://dk.co.nz/seo.

Regards,

DK

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.