Forum Moderators: phranque
ErrorDocument 401 /errorpages/error-401.php
ErrorDocument 404 /errorpages/error-404.php
ErrorDocument 500 /errorpages/error-500.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^index\.html?$ / [NC,R=301,L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
###I STARTED SEEING THE REDIRECT LOOP WHEN I INTRODUCED THIS CONDITION####
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteRule ^(.*) http://www.example.com/? [L,R=301]
###I STARTED SEEING THE REDIRECT LOOP WHEN I INTRODUCED THIS CONDITION####
RewriteCond %{REQUEST_URI} /galleries/$
RewriteRule ^(.*) http://www.example.com/galleries/index.php [L,R=301]
RewriteCond %{QUERY_STRING} ^cat=0$
RewriteCond %{REQUEST_URI} /galleries/index.php$
RewriteRule ^(.*) http://www.example.com/galleries/index.php? [L,R=301] [edited by: eelixduppy at 1:29 am (utc) on Dec 1, 2011]
[edit reason] exemplified [/edit]
I'm working on the suggestions I received in my previous posts
Use example.com in this forum. It stops the URL auto-linking process.
Never redirect to a named index file. The correct URL ends with a trailing slash.
Redirects should be listed in order from most specific to most general.
The non-www/www redirect must be last.
Literal periods in patterns must be escaped.
The index redirect RewriteCond needs to test THE_REQUEST to avoid the redirect loop.
I'll google THE_REQUEST and learn how to use it!
The index redirect RewriteCond needs to test THE_REQUEST to avoid the redirect loop.
[edited by: g1smd at 2:56 pm (utc) on Dec 1, 2011]
You then request http://example.com/ and the internal REQUEST_URI file pointer is updated (rewritten) by Apache to point to index.php so that the file can be fetched.