Adam
Adam

Reputation: 20952

.htaccess - infinite loop

I'm getting an infinite loop on this site - http://www.salesmelbourne.com

below is the .htaccess and I know the problem is in the last 4 lines - well I think so - can some offer some advice... thx

 php_value session.gc_maxlifetime 259200
 php_flag register_globals off
 php_flag zlib.output_compression on
 php_flag output_compression_level 6

 <Files *>
 Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
 Header set Expires: 0
 Header set Pragma: no-cache
 </Files>

 # File Upload 25MB
 php_value post_max_size 20M
 php_value upload_max_filesize 20M
 php_value max_execution_time 1000

 # use utf-8 encoding for anything served text/plain or text/html
 AddDefaultCharset utf-8

 # force utf-8 for a number of file formats
 AddCharset utf-8 .html .css .js .xml .json .rss .php
 RewriteEngine on
 RewriteCond %{HTTP_HOST} !^www\. [NC]
 RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]

 # Internally redirect all pages to index.php
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^/ajax/pages/(.*)$ /www/ajax/pages/404_error.php [R=301]
 RewriteRule . index.php [L]

Upvotes: 1

Views: 201

Answers (1)

LazyOne
LazyOne

Reputation: 165443

# Internally redirect all pages to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/ajax/pages/(.*)$ /www/ajax/pages/404_error.php [R=301]
RewriteRule . index.php [L]

What line #2 (from the end) does? It is not suppose to work anyway, since URL pattern in RewriteRule starts with NO leading slash, but you have it there (^/ajax/pages/(.*)$).

Since I do not know how that particular rule is expected to be working, there are 2 possible solutions (both will work -- it's all about the aforementioned line -- does it need those 2 conditions to function properly or not):

# I have no idea how this rule is supposed to work, but assume it's the way to go
RewriteRule ^ajax/pages/(.*)$ /www/ajax/pages/404_error.php [R=301]

# Internally redirect all pages to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

or like this (if those conditions are important for that rule)

# I have no idea how this rule is supposed to work, but assume it's the way to go
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ajax/pages/(.*)$ /www/ajax/pages/404_error.php [R=301]

# Internally redirect all pages to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

Upvotes: 1

Related Questions